[l2h] pdftex & latex2html

Ross Moore Ross Moore <ross@ics.mq.edu.au>
Sat, 29 Jan 2000 08:08:54 +1100 (EST)


> Hi!
> 
> To use latex and pdftex in parallel I use the suggested sequence:
> 
> \newif\ifpdf
> \ifx\pdfoutput\undefined
>    \pdffalse
> \else
>    \pdfoutput=1
>    \pdftrue
> \fi
> 
> with later use of \ifpdf.
> 
> However this does not work with latex2html, since even the parts with
> 
> \ifpdf
> % code
> \fi
> 
> seams to be executed!
> 
> 
> Any idea? What am I doing wrong?
 
Yes.
LaTeX2HTML is not based on a conventional TeX engine.
Its order of expansion is quite different, so constructions
using the TeX promitives \if \ifx \ifnum \ifdim etc.
are not reliable. Do not use them directly.

For conditional code portions, use instead:

\begin{htmlonly}
 ....
\end{htmlonly}
 and
\begin{latexonly}
 ...
\end{latexonly}
  from the  html.sty  package

and the special comments:

%begin{latexonly}
%end{latexonly}


Thus a file having portions conditional to each of
pdf-LaTeX, LaTeX and LaTeX2HTML  could look like:

\begin{htmlonly}
 .... the HTML bit ...
\end{htmlonly}
%begin{latexonly}
\ifpdf
 .... the pdf bit ...
\else
 .... the LaTeX/dvi bit ...
\fi
%end{latexonly}



The source looks rather messy with lots of these.
A better strategy is to define a macro for each such
conditional portion. However the macro has a different
expansion for each translation engine.

viz.

%begin{latexonly}
\ifpdf
 \newcommand{\figureA}{... code for fig A for pdf ...}
 \newcommand{\figureB}{... code for fig B for pdf ...}
 \newcommand{\figureC}{... code for fig C for pdf ...}
 ...

\else
 \newcommand{\figureA}{... code for fig A for dvi-based LaTeX...}
 \newcommand{\figureB}{... code for fig B for dvi-based LaTeX...}
 \newcommand{\figureC}{... code for fig C for dvi-based LaTeX...}
 ...

\fi
%end{latexonly}
\begin{htmlonly}
 \newcommand{\figureA}{... code for fig A for HTML pages ...}
 \newcommand{\figureB}{... code for fig B for HTML pages ...}
 \newcommand{\figureC}{... code for fig C for HTML pages ...}
 ...
\end{htmlonly}


Hope this helps,

	Ross Moore


> Joerg
> 
> --
> Joerg Broeker                 Technical University of Vienna
> e9125149@student.tuwien.ac.at or broeker@ict.tuwien.ac.at
> Tel.: +43/2236/29336 Fax.: +43/2236/24742/17 Mobile: +43/676/4632438
> Welcome - Das Reisemagazin: http://stud1.tuwien.ac.at/~e9125149/
> 
>