7

I'm trying to convert a LaTeX document to a webpage that'll be hosted on a server that's capable of processing and rendering simple TeX equations, but not doing section-level formatting.

So I'm trying to convert the document to HTML using TeX4ht, but leave the equations in the form $ my-eq-here $ in the resulting HTML to have the server process them and be able to modify them later. Any ideas on how to accomplish this using TeX4ht?

0

1 Answer 1

7

htlatex provides support for jsMath out of the box:

htlatex file "xhtml,jsmath" " -cmozhtf"

If you need output for a different engine, htlatex offers fine control on how math is to be output. In the Q/A section of the manual an example is shown that can be adapted to any use case.

To output the original LaTeX source surrounded by $ signs, create a file my.cfg in the same directory as the main .tex file with the following contents:

\Preamble{html}
\newtoks\eqtoks 
\def\AltMath#1${\eqtoks{$#1$}% 
   \HCode{\the\eqtoks}$}
\Configure{$}{}{}{\expandafter\AltMath}  
\begin{document} 
\EndPreamble

Now the command

htlatex file 'my'

produces a HTML file where the all inline equations are represented as their (equivalent) LaTeX source.

You can use the same switches after my as with html. Replace {html} by {xhtml} in my.cfg to get XHTML output.

1
  • A spurious space appears in commands that take arguments: If I compile $\mathbb{A}$, $\mathrm{A}$, $\text{A}$ I get $\mathbb {A}$, $\mathrm {A}$, $\text {A}$. How can I get rid of the extra space?
    – Manu
    Commented May 1, 2018 at 15:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .