2

I am using MikTeX with Windows 7. I have installed tex4ht using the package manager. The conversion of formulae are not ideal. Some formulae seem a bit choppy while others seem very horrible.

Example of Choppy-looking formula.

enter image description here

Example of horrible-looking formula.

enter image description here

and

enter image description here

Is there a way to fix this?


Updated question

After the suggestion of michal.h21, the output looked a little bit better.

enter image description here

However the inline formulae needs a bit improvements. For example

enter image description here

and

enter image description here

Some \begin{array} equations also needs improvements.

for example - Look at the minus sign and size of u. enter image description here

I would like to point out in order to write the derivatives I am using a

\newcommand{\Dn}3{\frac{\text{d}^#1 #2}{\text{d}#3^{#1}}} % for n-th derivative

I don't know if this should make any difference or not.

This is the link to my code which was requested by Sebastiano.

3
  • 2
    Can you add your code *.tex, please?
    – Sebastiano
    Mar 18, 2017 at 8:27
  • Maybe you should have a look at the available options (MathML, Other Options).
    – epR8GaYuh
    Mar 18, 2017 at 8:42
  • just use svg for math and everything will be just fine.
    – Nasser
    Mar 19, 2017 at 22:04

1 Answer 1

9

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:

enter image description here

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:

enter image description here

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:

enter image description here

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.

You must log in to answer this question.

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