[pdftex] conditional compiling - test if pdfoutput is undefined

jwithey at diaphor.net jwithey at diaphor.net
Fri Nov 2 13:21:47 CET 2001


Hi, all.

I am designing a generic preamble for compiling LaTeX source using either
PDFTeX or TeX4ht.  I am using MiTeX 2.1.

Is there a robust way to test if pdfoutput has been defined by PDFTeX?

Because the ifthen package requires commands to be defined, I tried the
following

\providecommand{\pdfoutput}{0}
\ifthenelse{\pdfoutput=1}{%set to 1 by pdftex.cfg
    options, fonts and formatting for pdftext
}{
    options, fonts and formatting for dvips (TeX4ht html)
}

This works except that the MiKTeX configuration files, graphics.cfg and
color.cfg test whether pdfoutput is undefined.  These files are read when
the color and graphics packages are requested.

Placing all commands that use the color and graphics packages before the
above test works, but I believe this adds preconditions not normally assumed
by a user or developer, and thus will be hard to maintain.

I am not sure what to do with hyperref, since the package writers recommend
placing that package last in the preamble.  I could place all \usepackage
commands inside the test, but would prefer to keep device differences
transparent and to avoid considerable duplication.

I tried the TeX command \@ifundefined as described in \textit{A Guide to
LaTeX} but the compiler parses \@ as a spacing command and generates an
error.  Turning on \frenchspacing may work, but again this solution seems a
hack.

Any suggestions on how to do this in LaTeX?  If TeX conditionals must be
used, what is the risk of obsolescence, portability etc?




More information about the pdftex mailing list