It seems that Miktex haven't updated the last fixes regarding default quality of images in tex4ht
. It uses dvipng
for the conversion now, and the quality got much better. There are also other alternatives, such as to use vector SVG
images, or to use MathML
with Mathjax
library for rendering.
You can easily use the better methods in Miktex
as well, using make4ht
build files. Save the following code as mybuild.mk4
:
Make:image("png$","dvipng -bg Transparent -T tight -D151 -o ${output} -pp ${page} ${source}")
Make:image("svg$","dvisvgm -n -p ${page} -c 1.4,1.4 -s ${source} > ${output}")
You can compile your file using
make4ht -ue mybuild.mk4 filename.tex
For the following nonsensical math sample:
\documentclass{article}
\begin{document}
\[
\left(-\frac{{h}^{2}}{2m}\delta-\frac{{e}^{2}}{4\pi} \right) = \theta
\]
\end{document}
You will get the following png
picture:

To get the svg
image, you need to use small configuration file, mycfg.cfg
:
\Preamble{xhtml}
\Configure{Picture}{.svg}
\begin{document}
\EndPreamble
It requires the output format for the pictures to be the svg
format.
You can request the config file in the compilation using
make4ht -ue mybuild.mk4 -c mycfg.cfg filename.tex
And this is the result. Note that it is blurred because it is screenshot from the browser, Stackexchange doesn't support SVG
image upload. It looks better in the reality:

The last possibility is to use MathML
with MathJax
. Use the following config file, mathjax.cfg
:
\Preamble{xhtml,mathml}
\Configure{@HEAD}{\HCode{\Hnewline<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_CHTML">
</script>\Hnewline}}
\begin{document}
\EndPreamble
compile the document using
make4ht -uc mathjax.cfg filename.tex
This is the result:

You can try also other options for MathJax
output, see MML_SVG
and MML_HTMLorMML
in the MathJax documentation. You can put those options in the configuration file after MathJax.js?config=
. I think the MML_CMATH
is preferred nowadays, but the other options may work better for you.
*.tex
, please?MathML
,Other Options
).