Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detecting Tex4HT

48 views
Skip to first unread message

czwang

unread,
May 7, 2002, 9:13:26 PM5/7/02
to
I would like to run both PdfLatex and Tex4HT on my tex file, which
inlcude tex4ht special macros such as:

\ifHtml \HCode{...} \fi

However, this causes problems when running PdfLatex. Is there a way to
detect whether the tex4ht package is loaded so that we can ignore the
above segment when tex4ht is not used?

\ifTex4ht \ifHtml \HCode{...} \fi \fi

By the way, I did not declare tex4ht package in my tex file, Instead,
the tex4ht command itself will load in the package for me.

Thanks in advance!
-czwang

Eitan Gurari

unread,
May 8, 2002, 3:30:46 AM5/8/02
to

> I would like to run both PdfLatex and Tex4HT on my tex file, which
> inlcude tex4ht special macros such as:
>
> \ifHtml \HCode{...} \fi

I believe it is a wrong approach to include translator-dependent code
within source files. Tex4ht offers an alternative route through local
configuration files. For instance, the command line

htlatex file "foo"

expects a private configuration file foo.cfg of the form

\Preamble{html}
\begin{document}

... private definitions and configurations ...

\EndPreamble



> However, this causes problems when running PdfLatex. Is there a way to
> detect whether the tex4ht package is loaded so that we can ignore the
> above segment when tex4ht is not used?
>
> \ifTex4ht \ifHtml \HCode{...} \fi \fi

e.g.,

\ifx\HCode\UnDef\else \HCode{...} \fi

-eitan


Anthony Williams

unread,
May 8, 2002, 3:38:12 AM5/8/02
to
"czwang" <changz...@yahoo.com> wrote in message
news:edfc77f.02050...@posting.google.com...

> I would like to run both PdfLatex and Tex4HT on my tex file, which
> inlcude tex4ht special macros such as:
>
> \ifHtml \HCode{...} \fi
>
> However, this causes problems when running PdfLatex. Is there a way to
> detect whether the tex4ht package is loaded so that we can ignore the
> above segment when tex4ht is not used?
>
> \ifTex4ht \ifHtml \HCode{...} \fi \fi

I use

\newif\ifhttex \ifx\HCode\undefined \httexfalse \else \httextrue \fi

quite successfully (along with \ifpdf)

Anthony
--
Anthony Williams
Software Engineer, Nortel Networks Optical Components Ltd
The opinions expressed in this message are not necessarily those of my
employer


Rakesh Vidyadharan

unread,
May 8, 2002, 3:07:03 PM5/8/02
to

I use the optional.sty package to do conditional code.


\usepackage{optional}
% \opt{dvi}{DVI specific text}
% \opt{html}{HTML specific text}
% \opt{pdf}{PDF specific text}
% \opt{ps}{PostScript specific text}
\newcommand{\ExplainOptions}{dvi = DVI output, html = HTML output, pdf
= PDF output, ps = PostScript output}
\AskOption

I then mark the pdf specific text with \opt{pdf}{pdf
specific}\opt{html}{html specific} ....

The down-side is that you will always have to specify which
conditional text you wish processed when you run latex.
--
/***************************************************/
/* Rakesh Vidyadharan */
/* Applications Specialist, Tribune Media Services */
/***************************************************/

0 new messages