[Tex/LaTex] on Tex4ht conversion to HTML, can this conversion be improved

latex2htmltex4ht

I have been trying tex4ht and comparing its output to Latex2html (l2h).

I still find l2h to produce better math in the HTML than tex4ht. But it could be I am not doing something right and I thought to check with the experts here.

I'll show a very small example, and show the commands used, and show the output I get from l2h and tex4h. Clearly the l2h Math looks better. The math from tex4h is not straight on the same line as the text around it, also the \prime shows up like just a straight up tick instead of a real math \prime. Also some letters with tex4ht seems to be fussy looking, while other Math letters seems to be sharp. Also the letter v looks different from a real v letter in math mode.

I hope someone can spot something I am doing wrong when it comes to using tex4ht

Here is the tex file:

\documentclass[12pt]{article}%
\usepackage{html}
\begin{document}

Where $\left[M\right]_{v^{\prime}\to v}$ is the change of basis matrix which
when applied to $\mathbf{x}_{v^{\prime}}$ returns the coordinates of the
vector w.r.t. basis $v$

\end{document}

Here is the Latex2html and htlatex commands used to make the HTML

latex2html t4.tex
htlatex t4.tex

Here is a screen shot of the output from l2h

enter image description here

Here is a screen shot of the output from tex4ht

enter image description here

specs

Linux mint xfce 14, tex4ht

tex4ht -v
tex4ht.c (2009-01-31-07:33 kpathsea)

latex2html -v
This is LaTeX2HTML Version 2008 (1.71)

latex -v
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
kpathsea version 6.1.0

Update

Thanks to suggestion by @cmhughes below, I tried the command suggested. It improved the output for sure, but the -> has too much spaces between them. Here is a screen shot as seen on Chrome browser (same browser used for the above screen shots). But I would use over the last command.

   mk4ht mzlatex t4.tex "html,mathplayer"

and now looking at the file 4.xht

enter image description here

btw, when I tried the above mk4ht command on other latex documents I have, I now get syntax errors which do not show up when I use the command htlatex foo.tex. Here is one example:

mk4ht mzlatex report.tex "html,mathplayer"

! Display math should end with $$.
<to be read again> 
                   \bgroup 
l.470 \end{equation}

? 

So, I am not sure I want to use this command if I have to go now edit all my latex files again to make it work with mathml generation. I do not know what other incompatibilities this will bring up and if I do this change, will the file work again with Latex?

Best Answer

Another possible solution is to change the default density when tex4ht calls imagemagick's convert in tex4ht.env.

This is at line 167 in my version where it says:

G.
Gif exist zz%%4.ps DEL zz%%4.ps >nul
Gif exist %%3 DEL %%3 >nul
Gdvips -E -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
Gconvert -trim +repage -density 110x110 -transparent "#FFFFFF" zz%%4.ps %%3
Gif exist zz%%4.ps DEL zz%%4.ps >nul  

Just change 110x110 to 500x500. Actually for your inline example this makes an appropriately high resolution [M], but much too large so this would need to be tweaked, possibly with the line above as well.

Maybe this could be done in a configuration file instead, so the original file isn't modified.

Related Question