[l2h] Cannot get htmlonly to work in a macro

Ross Moore Ross Moore <ross@ics.mq.edu.au>
Thu, 27 Jan 2000 23:07:30 +1100 (EST)

> The following macro used to work.... but now breaks latex on the htmlonly
> part.

Did it really used to work, in that form ?

Environments like {htmlonly} are  verbatim-like for LaTeX.
Thus they are fragile and do not work well, if at all,
when used within macro definitions.

> ! LaTeX Error: Not in outer par mode.

Typical symptom of this type of problem.

> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...                                              
> l.133 \figuregif[scale=0.5]{mo
>                               ve-valve-op-exp}{Example of a OP}{fig-proc1-fig}
> You've lost some text.  Try typing  <return>  to proceed.
> If that doesn't work, type  X <return>  to quit.
> Any way to fix it?

Yes. Don't put the conditional code *inside* the macro expansion.
Instead have conditional macro definitions:


  .... what you want it to do in LaTeX ...
  .... what you want it to do in LaTeX2HTML ...

Note that this is more efficient anyway, since you are not testing
the condition at each usage, but just working with the desired coding.

> \newcommand{\figuregif}[4][]%
> {
> \begin{figure}
> \begin{makeimage}
> \end{makeimage}
> \begin{latexonly}
> \begin{center}
> \includegraphics[#1]{#2.ps}
> \end{center}
> \end{latexonly}
> \begin{htmlonly}
> \htmladdimg[center]{gif/#2.gif}
> \end{htmlonly}
> \caption{#3}
> \label{#4}
> \end{figure}
> }

Hope this helps,

	Ross Moore