1

Is there a way to programatically test whether the current document is being compiled by tex4ht?

What I am looking for is something like \iftexfourht, or perhaps some \@ifundefined{...}, in order to make \variable expand either to $#1$ or to \textit{#1} conditionally upon whether or not tex4ht is in charge.

\documentclass{article}

\newcommand \variable [1]
{%
 \iftexfourht
  \textit{#1}%
 \else
  $#1$%
 \fi
}

\begin{document}
Let's talk about \variable{x}.
\end{document}
1
  • \@ifundefined{HCode}{NO HT}{YES HT}, but I wouldn't rely on it; anybody can define anything, so someone can define \HCode even tex4ht is not active. – yo' Sep 3 '16 at 15:15

Browse other questions tagged or ask your own question.