Hello,

I had a problem when using

   hyperlatex -image

in conjunction with the default \htmldirectory{.}.

hyperlatex produces a file.makeimage with the command

   mv file.png .

Of course this results in an error since the file is already there and
cannot be moved to itself.

Yes, it would be possible to convince my Makefile to ignore such an
error, but I think I have another solution. See the modified files in
the attachment.

hyperlatex.sty:
   I have modified \endimage to produce a command suitable for the
   modified ps2image. So instead of

   ps2image -png ... file.ps > file.png
   mv file.png .

   it will produce

   ps2image ... file.ps htmldir/file.png

ps2image:
   This script recognises the target filetype from a parameter that ends
   in .png or .gif. The extension .ps is always assumed to be the input
   filename.
   Since the target filename includes the targed directory, an additional
   move of the file is unnecessary.

   It even seems ps2image is a bit shorter. ;-)


The only problem that remains is the following. It is now possible to say

\begin{image}{dir/file} ... \end{image}

and the picture file.png (or file.gif) will be generated in the
subdirectory 'dir', but only if 'dir' already exists. There is no code
at the moment, that would generate such a missing directory.

Maybe I could think about putting some extension code into my rhxxname
package, but this will take some more spare time.

Best regards
Ralf

#! /bin/sh
# convert ps file to Gif
#
resolution=95
quantcmd="cat"
transcmd="-transparent #ffffff "
antialiasing=""
#
usage() {
  echo "Usage:" 1>&2
  echo "  ps2image [ -res RESOLUTION ] [ -notrans ] psfile.ps file.png" 1>&2
  echo "  ps2image [ -res RESOLUTION ] [ -notrans ] psfile.ps file.gif" 1>&2
  echo " " 1>&2
  exit 1
}

[ $# -lt 2 ] && usage

while [ $# -gt 0 ]; do
  case $1 in
    -quant)
      quantcmd="ppmquant 50"
      ;;
    -notrans)
      transcmd=""
      ;;
    -antialiasing)
      antialiasing="-dTextAlphaBits=4 -dGraphicsAlphaBits=4"
      ;;
    -res)
      shift
      if [ $# -eq 0 ]; then
        echo "ps2image: no resolution specified" 1>&2
        exit 1
      fi
      resolution=$1
      ;;
    -*)
      usage;;
    *.ps)
      fig=$1;;
    *.png)
      image=$1; convertcommand="pnmtopng";;
    *.gif)
      image=$1; convertcommand="pnmtogif";;
  esac
  shift
done

cat $fig \
| gs -q -dNOPAUSE -r$resolution $antialiasing -sDEVICE=ppm -sOutputFile=- - \
| pnmcrop | $quantcmd | $convertcommand -interlace $transcmd > $image

echo "Done"

%%
%% LaTeX style to handle hyperlatex files, version 2.4
%%
%% This code has GNU copyleft, 1994-2000 Otfried Cheong
%%
\NeedsTeXFormat{LaTeX2e}

\ProvidesPackage{hyperlatex}
[2004/05/02 v2.7 LaTeX2e package for Hyperlatex mode]

\typeout{Package: 'hyperlatex' v2.7  Otfried Cheong}

\RequirePackage{verbatim}
\chardef\other=12

%%
%% Comments,  
%%
[EMAIL PROTECTED]
[EMAIL PROTECTED]

\newcommand{\htmlonly}[1]{}
\newcommand{\texorhtml}[2]{#1}
\newenvironment{iftex}{}{}
\newenvironment{latexonly}{}{}
\newcommand{\texonly}[1]{#1}
\newcommand{\T}{}

%%
%% Treatment of special characters
%%

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]@[EMAIL PROTECTED]
[EMAIL PROTECTED]

\let\htmltab=&

%%
%% \begin{tex} ... \end{tex}    escapes into raw Tex temporarily.
%% you can write {\tex .....} as well, if already escaped from Html
%%
\newenvironment{tex}{\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
\catcode `\^=7 \catcode `\_=8 \catcode `\%=14}{}

%%
%% \back
%% 

\newcommand{\back}{{\tt\char`\\}}

%%
%% \math
%%

[EMAIL PROTECTED] [EMAIL PROTECTED]@math[]}}
[EMAIL PROTECTED]@@math}
\def\@@math#1{$#1$\endgroup}

%%
%% Commands that don't do anything interesting in Latex
%%

[EMAIL PROTECTED]@[EMAIL PROTECTED]@sanitize}


[EMAIL PROTECTED]
%-- Never allow [EMAIL PROTECTED] to be empty. See \endimage.

[EMAIL PROTECTED]
\newcommand{\htmlname}[1]{}
\newcommand{\htmldepth}[1]{}
\newcommand{\htmltopname}[1]{}
\newcounter{htmldepth}
\newcommand{\htmltitle}[1]{}
\newcommand{\htmladdress}[1]{}
[EMAIL PROTECTED]@html}
[EMAIL PROTECTED]
\let\html\xml

\newcommand{\xmlsym}[1]{}
\newcommand{\htmlrule}{}

\newcommand{\htmlmenu}[1]{}
\newcommand{\htmlautomenu}[1]{}
\newcounter{htmlautomenu}
\newcommand{\htmlprintindex}{}
\newcommand{\htmlfootnotes}{}
\newcommand{\htmlmathitalic}[1]{}
\newcommand{\htmlpanelfield}[2]{}
\newcommand{\htmlcharset}[1]{}
\newcommand{\htmlcss}[1]{}

\newcommand{\htmlimg}[2]{}

[EMAIL PROTECTED]@ignore}
[EMAIL PROTECTED]

\newcommand{\htmlpanel}[1]{}
[EMAIL PROTECTED]@[EMAIL PROTECTED]
[EMAIL PROTECTED]

\newcommand{\htmlcaption}[1]{}

[EMAIL PROTECTED]@[EMAIL PROTECTED]
[EMAIL PROTECTED]@pass\@@xmlattributes}
\def\@@xmlattributes#1#2{\endgroup}
\let\htmlattributes\xmlattributes

%%
%% Image environment,
%% will generate bitmaps when `\makeimages' is defined
%% `\imagetype' will determine the type of images

[EMAIL PROTECTED]

[EMAIL PROTECTED]@[EMAIL PROTECTED]

[EMAIL PROTECTED]
[EMAIL PROTECTED]@[EMAIL PROTECTED]

[EMAIL PROTECTED]@[EMAIL PROTECTED]
[EMAIL PROTECTED]@ifnextchar[{\@@image}{\@@image[100]}}
\def\@@[EMAIL PROTECTED]@ifnextchar[{\@@@image}{\@@@image[300]}}
\def\@@@[EMAIL PROTECTED]@name{#2}\@@@@image}

[EMAIL PROTECTED]
\typeout{******************************************}
\typeout{* Making bitmaps from Hyperlatex source! *}
\typeout{******************************************}
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]@imagecount=10000
\def\@@@@[EMAIL PROTECTED]
\def\endimage{\egroup
  [EMAIL PROTECTED] by [EMAIL PROTECTED]
    [EMAIL PROTECTED] -f\space -p\space
      [EMAIL PROTECTED] -n\space 1\space -D\space [EMAIL PROTECTED]
      [EMAIL PROTECTED],[EMAIL PROTECTED],-72bp\space
      \jobname.dvi\space>[EMAIL PROTECTED]
      ps2image\space -res\space [EMAIL PROTECTED] [EMAIL PROTECTED]
      \space [EMAIL PROTECTED]/[EMAIL PROTECTED]@imagetype^^J}
    [EMAIL PROTECTED]@imagebox}
\else
\def\@@@@image{\tex}
\def\endimage{}
\fi

%% For compatibility
\def\gif{\imagetype{gif}\image}
\def\endgif{\endimage}

%%
%% Font style definitions
%%

\let\cit=\textit
\let\code=\texttt
\let\kbd=\texttt
\let\samp=\texttt
\let\strong=\textbf
\let\var=\textsl
\let\dfn=\textit
\let\file=\textit

%%
%% \begin{example} ... \end{example} obeys spaces and lines
%%
[EMAIL PROTECTED]&\do\#\do\^\do\_\do\~}
{\obeyspaces
  [EMAIL PROTECTED] =\ [EMAIL PROTECTED]
{\obeylines%
  [EMAIL PROTECTED]

\def\example{\list{}{\leftmargin\z@
    \itemindent\z@ \rightmargin\z@ \parsep \z@ [EMAIL PROTECTED]
  [EMAIL PROTECTED]@[EMAIL PROTECTED]@example}
\let\endexample=\endlist

%%
%% font problem:  math in example environment seems to need this:
%%
\DeclareFontFamily{OMS}{cmtt}{}
\DeclareFontShape{OMS}{cmtt}{m}{n}{ <-> ssub * cmsy/m/n }{}

\newenvironment{menu}{\list{$\bullet$}{\itemsep0pt\parsep0pt}}{\endlist}
\newenvironment{ifhtml}{\comment}{\endcomment}
\newenvironment{rawxml}{\comment}{\endcomment}

\def\xmlinclude#1{}

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

[EMAIL PROTECTED]@[EMAIL PROTECTED]
    [EMAIL PROTECTED]@Hlxfalse
    [EMAIL PROTECTED]@Hlxfalse
    [EMAIL PROTECTED]

[EMAIL PROTECTED]
  [EMAIL PROTECTED]
  %% arg true -> skip
  [EMAIL PROTECTED]
  \else
  %% arg false -> ignore begin and end
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]

[EMAIL PROTECTED]
  [EMAIL PROTECTED]
  % arg true -> ignore begin and end
  [EMAIL PROTECTED]
  \else
  % arg false -> skip environment
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]

%%
%% Define \link and \xlink macros
%%
[EMAIL PROTECTED]

[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]

[EMAIL PROTECTED]@label{\label{#1}}\ignorespaces}%
[EMAIL PROTECTED]@label\ignorespaces}

\newcommand{\htmlcite}[1]{\cite{#1}}

[EMAIL PROTECTED]@[EMAIL PROTECTED]@@link}}
\def\@@link#1{#1\@@@link}
[EMAIL PROTECTED]@link#1{\@@@link}
\def\@@@[EMAIL PROTECTED] [EMAIL PROTECTED] ] balance
  [EMAIL PROTECTED]
[EMAIL PROTECTED]@label{#2}#1}

[EMAIL PROTECTED]@[EMAIL PROTECTED]@@xlink}}
\def\@@xlink#1{\@@@xlink{#1}}
[EMAIL PROTECTED]@xlink#1{\@@@xlink{}}
\def\@@@[EMAIL PROTECTED] [EMAIL PROTECTED]@xlink{#1}[]}}
[EMAIL PROTECTED]
\newcommand{\formatxlink}[2]{#1}

%
% index from latex.tex, and changed to include optional argument
%
[EMAIL PROTECTED]
  [EMAIL PROTECTED]@noexpand
  [EMAIL PROTECTED]
  [EMAIL PROTECTED] [EMAIL PROTECTED] balance ]
  [EMAIL PROTECTED]
[EMAIL PROTECTED]@[EMAIL PROTECTED]

%% end of hyperlatex.sty

Reply via email to