Increase equation resolution in TeX4ht using accessible images or typeset text

When TeX4ht compiles my latex code it generates a png of my equation and includes this in the html file. Until a better alternative for this comes along I am quite happy with this way of managing/presenting my equations.

This is a collaborative project and I am working with some very anti-latex and anti software people, so I generate html files that they can edit. By ensuring complete compatibility between the html file and pdf generation everyone remains happy. I would however prefer to have a higher resolution image that my collaborators can read without getting frustrated with the document quality.

Approaches I have investigated and been unsuccessful with:

1. An excellent explanation that I apologize for missing during my initial week spent trying to solve this issue here LaTeX --> (X)HTML with tex4ht: bad quality images of equations uses a conversion of eps to svg.

Unfortunately eps are not file extensions that my collaborators can open, nor is it something they are willing or even capable to upgrade software to work with. So This solution is not my preferred approach unless the final image type is not an eps.

I am sure I am not doing something quite right with the implementation of this as on our work computers I am left only with the eps file, no png or svg are created, and browser/editable integration of the eps is hit or miss. If memory serves, the mentioned convert program is part of imagemagick which we do have installed, so I am at a loss why the svg or png creation is absent using the custom cfg file mentioned in the solution. Maybe this should be the question itself which I believe is completely distinct albeit related to the question that this is currently marked as a duplicate for.

1. It might be neat to use a completely different approach maybe using http://latex2html5.com which honestly I haven't even been able to figure out how to compile their examples - but I feel it holds promise for the issue I described above if I can figure out what it is supposed to do and how to do it (unless this tool is the best option to solve my problem, this is a question for another day which I will post and edit this question to remove this aspect to prevent duplication). One aspect of this approach that would interest me, is the appearance that this is not a picture, but formatted text...

Here is my MWE.

\documentclass{report}
\usepackage{amsmath}
\begin{document}
$$\text{C~=~}{\frac{a}{b}}$$
\end{document}


There are several approaches described in the linked answer. Route from eps to output formats is the default way tex4ht deals with generated images. You shouldn't get eps images as final format, it is always converted to something which can be displayed with a browser.

another way is to use some dvi to image converter such as dvipng or dvisvgm. To avoid need to modify the .env file, which was in depth described in the linked answer, I will show solution using make4ht.

create a build file, named as texfilename + .mk4 suffix:

Make:htlatex{}
Make:image("png$","dvipng -bg Transparent -T tight -D151 --freetype -o${output}  -pp ${page}${source}")
Make:image("svg$","dvisvgm -n -p${page} -c 1.4,1.4 -s ${source} >${output}")


this build file calls htlatex only once, as you don't use hyperlinks and references, which need more htlatex runs.

Make:image declaration are used depending on the used image output (which can be configured). for png output, dvipng is used, for svg, it is dvisvgm. you can set the image resolution with -D option for dvipng and -c option for dvisvgm, you need to try some values, which one will fit your text best.

for png output, compile with

make4ht filename


the result:

to compile to svg, you need to configure image output, for example with such config file., hello.cfg:

\Preamble{xhtml}
\Configure{Picture}{.svg}
\begin{document}
\EndPreamble


compile now with

make4ht -c hello filename


and the output:

you may need to read man pages for dvipng or dvisvgm and play with parameters to suit your needs

• Is your second stage for the svg compilation dependent on the make4ht compile? This is the step that in my question I am not sure what prerequisite program is required/why my system can't see it (in addressing the first part of your answer, I definitely don't get any files other than eps - so if possible I would like to fix that problem). – EngBIRD Jan 27 '15 at 16:30
• Actually I think the first stage question I could use some elaboration on is "Can make4ht be installed on a windows system with MikTex"? I just realized that mk4ht and make4ht are not the same thing, Duh! – EngBIRD Jan 27 '15 at 16:50
• @EngBIRD detailed install instructions for Windows with TeXLive (but it should be similar with Miktex) are here: d800fotos.wordpress.com/2015/01/19/… – michal.h21 Jan 27 '15 at 19:11
• How is make4ht converted to a recognized executable file? I think the only thing different on the installation of miktex vs texlive is the absence of a texmf directory, but since it is easy to add a root to miktex, I believe these should be equivalent. However, the make4ht file has no extension and windows can't recognize this as program to be run. I have tried running this command line directive having set this up as an environment variable and an explicit file path to this file. Thanks for your assistance. – EngBIRD Jan 27 '15 at 22:32
• @EngBIRD you need to create a batch file in form of texlua "C:\path\to\local\texmf\scripts\lua\make4ht\make4ht" %* and place it somewhere in the pat, so it can be called from anywhere – michal.h21 Jan 27 '15 at 22:57