It is much easier to write my texts in an editor with LaTeX, but often clients ask for a word file.

tex4ht does a good job, it produces html from a tex-file, which can be easily used. But there are some packages which cause errors, e.g. the §-sign of Linux Libertine. Is it possible to have a command which makes pdflatex have a look whether it is run by htlatex?

I'd like to write something like


There are more things that don't work with htlatex, e.g. the machinery to name and count exhibitions and to produce a list of them at documents end. So something like \ifhtlatex would be helpfull.


I dont't want to load the tex4ht package itself, so I've no idea, how this question could be helpfull...

  • You mean something beyond \newif\ifhtlatex etc.? – jon Sep 11 '13 at 14:03
  • @DavidCarlisle I don't want to check for html or pdflatex! – Keks Dose Sep 11 '13 at 14:09
  • @jon No, I just have not idea how to detect whether htlatex called pdftex, or pdflatex. – Keks Dose Sep 11 '13 at 14:10
  • @KeksDose html in that question meant tex4ht the answer being essentially to use \@ifpackageloaded{tex4ht} as the tex4ht script adds that package to your document – David Carlisle Sep 11 '13 at 14:16
  • @DavidCarlisle Thank you, I did not know that. So the difference to the related question here (tex.stackexchange.com/questions/93852/…) is, that I just need to know tex4ht loaded or not, while there three options have to be checked. – Keks Dose Sep 11 '13 at 14:17

htlatex loads package tex4ht via the hook \@documentclasshook that is called at the end of the document class. Thus you can test for this package after \documentclass:


Before \documentclass the macro \HCode could be checked that is defined by htlatex, e.g.:

  • Why \UnDeFiNeD with this capitalization? – musarithmia Jun 20 '18 at 17:36
  • @musarithmia It does not matter any undefined command will do. "Funny" names are less likely to be defined. – Heiko Oberdiek Jun 20 '18 at 17:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.