How do I configure htlatex so that equations are not rendered as an image in a separate file, but within the document as in $x$? I still would like the ability to assign \label

1 Answer 1


I think that it is best to convert math to MathML and use MathJax to render it. Native LaTeX labels work with no problems this way.

All we need to do is to use simple config file, which will provide some JavaScript to load MathJax:

\HCode{<script type="text/javascript"

All what this does is that it selects MathML output in the \Preamble command and then include external script to load MathJax. Important piece is MathJax.js?config=MML_CHTML, which configures MathJax to parse only MathML and to select common html as the rendered format. MathJax by default also parse LaTeX math in the document, but we really don't need that, it would only slow down the processing.

Some sample document:



hello world

a = \sqrt{b^2 + c^2}

See equation~\ref{eq:hello}

Now some multiline

  p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\ 
  - 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3


  2x - 5y &=  8 \\ 
  3x + 9y &=  -12


  x&=y           &  w &=z              &  a&=b+c\\
  2x&=-y         &  3w&=\frac{1}{2}z   &  a&=b\\
  -4 + 5x&=2+y   &  w+2&=-1+w          &  ab&=cb


We can compile it using

make4ht -uc configfilename.cfg filename.tex

and the result looks this way:

enter image description here

  • I upvoted and I'll play around with this, thanks, but right now I was just looking to reproduce the same behavior as $...$ (which does not use mathjax). I don't want to use javascript here.
    – Manu
    Commented Oct 16, 2016 at 23:22
  • @EmanueleViola it works with $...$ as well. If you don't want to use JavaScript, then it is possible to install command line version of MathJax using node.js and convert the HTML file with MathML to simplified version. I can update the answer with an example.
    – michal.h21
    Commented Oct 17, 2016 at 6:30
  • I am trying to produce a very minimalistic html here that can be pasted into wordpress. Wordpress doesn't like javascript (as far as I can tell). The way $...$ is converted is just plain HTML, which Wordpress understands, but for some reason \begin{equation} is rendered as an image, which wordpress does not like.
    – Manu
    Commented Oct 17, 2016 at 12:43
  • @EmanueleViola ah I see. This might be useful then.
    – michal.h21
    Commented Oct 17, 2016 at 12:59

You must log in to answer this question.

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