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
Asked
Active
Viewed 541 times
3
Manu
- 493
1 Answers
5
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:
\Preamble{xhtml,mathml}
\Configure{@HEAD}{%
\HCode{<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_CHTML">
</script>\Hnewline}}
\begin{document}
\EndPreamble
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:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
hello world
\begin{equation}
\label{eq:hello}
a = \sqrt{b^2 + c^2}
\end{equation}
See equation~\ref{eq:hello}
Now some multiline
\begin{multline*}
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multline*}
Align:
\begin{align*}
2x - 5y &= 8 \\
3x + 9y &= -12
\end{align*}
Align*:
\begin{align*}
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
\end{align*}
\end{document}
We can compile it using
make4ht -uc configfilename.cfg filename.tex
and the result looks this way:
michal.h21
- 50,697

$...$as well. If you don't want to use JavaScript, then it is possible to install command line version of MathJax usingnode.jsand convert the HTML file with MathML to simplified version. I can update the answer with an example. – michal.h21 Oct 17 '16 at 06:30