4

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

 \ifhtlatex
\usepackage{lmodern}
\else 
\usepackage{libertine}
\fi

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...

Keks Dose
  • 30,892
  • 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 (http://tex.stackexchange.com/questions/93852/what-is-the-correct-way-to-check-for-latex-pdflatex-and-html-in-the-same-latex) 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
  • @KeksDose see the updated code in the referenced question (which should have been in an answer) \if\texforht seems to be exactly what you want – David Carlisle Sep 11 '13 at 14:19

1 Answers1

5

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:

\documentclass[...]{...}
\makeatletter
\newif\ifhtlatex
\@ifpackageloaded{tex4ht}{\htlatextrue}{\htlatexfalse}
\makeatother

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

\newif\ifhtlatex
\ifx\HCode\UnDeFiNeD
  \htlatexfalse
\else
  \htlatextrue
\fi
\documentclass{...}
Heiko Oberdiek
  • 271,626