Conditionals – Is There an \iftex4ht Command and How to Define It

conditionalstex4ht

Background: I'm using TikZ to generate a load of pictures that I want to put on the web as SVGs. So I'm using the pgfsys-tex4ht.def driver and it's working very well. My gut feeling is that the SVG output from TikZ/pgf is "experimental" so while designing the pictures, I'm not using a special driver but just generating the PDFs via pdflatex. Also, I want PDFs as well as SVGs at the end.

So rather than having to comment out the line

\def\pgfsysdriver{pgfsys-tex4ht.def}

each time, I'd rather have a switch that loaded it if tex4ht was loaded; that is, I already specify the output when I decide whether to run pdflatex or htlatex – I don't want to have to specify it twice. So, my question:

Is there an \iftex4ht somewhat akin to the \ifpdf provided by ifpdf.sty?
If not, what would be the "right" way to test for the presence of tex4ht?

Best Answer

There is always this:

\@ifpackageloaded{tex4ht}{LOADED}{NOT LOADED}

Suitable for other packages of interest as well, of course. (Usual caveats about @ character apply.)

Related Question