[l2h] \caption vs. \newfont?

Ross Moore ross@ics.mq.edu.au
Tue, 30 Jul 2002 06:45:34 +1000 (EST)


> Hi:
> 
> I'm using a macro to switch fonts inside a \caption.
> The font-switching macro is defined differently based on
> whether HTML is being produced.  Here's how I load the
> new font:
> 
>     \newfont{\ct}{cmtcsc10}	% fancy-looking small caps
> 
> Here's how I declare the font-switching macro
 
No don't do this:
>     % tart up a PDU type name
>     \latexhtml{\newcommand{\tartm}[1]{{\ct #1}}}
> 	      {\newcommand{\tartm}[1]{{\sc #1}}}

\latexhtml should only be used for static text which is different
between the LaTeX and HTML versions; it certainly should not be used
for conditional \newcommand definitions.


Instead use conditional comments for the LaTeX-only part:
  %begin{latexonly}
    \newfont{\ct}{cmtcsc10}	% fancy-looking small caps
    \newcommand{\tartm}[1]{{\ct #1}}
  %end{latexonly}

and have a separate conditional environment for HTML:

  \begin{htmlonly}
    \newcommand{\tartm}[1]{\textsc{#1}}
  \end{htmlonly}


These conditional parts are found by  texexpand 
so that the decision to include/exclude is made early in the processing.

With \latexhtml the full construction is carried along throughout
the whole process, with the final decision of what to include being
made very late.

> Finally, at the end of the run, I get a:
> 
>     Unknown commands: ct
> 
> How can I fix this?  If I just use \sc directly, as in
> 
>     \caption{blah {\sc dullsville}}
> 
> the HTML turns out just fine.  I'd like to keep the \tartm macro,
> though, if that's at all possible.
> 
> Any suggestions?

The above advice should fix it.
Also, it's much cleaner when you have lots of conditional definitions,
since you only need one conditional block for each processor,
rather than one use of \latexhtml for each conditional definition.


Hope this helps,

	Ross Moore

 
> Chris <jepeway@blasted-heath.com>.
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html