I noticed that in the html output from a tex4ht run, there are spaces after the \hat{}. However, in the dvips output, there are no spaces.

Is there a workaround for this? My guess is there needs to be a web-based amsmath file used.

enter image description here


After looking at @michal.h21's suggestion to use pic-m the results are outstanding. Below is the command line, and lower is the preamble. Using {xhtml} in the preamble alone worked well, and if {xhtml,mathml} is used, the images are not produced.

htlatex test.tex "myfile.cfg,charset=utf-8,pic-m" " -utf8 -cunihft"

and here is the preamble (contents of myfile.cfg):


   {\ifOption{refcaption}{}{\csname par\endcsname\ShowPar \leavevmode}}
{\ifvmode \IgnorePar \fi\EndP \HCode{}\csname par\endcsname\ShowPar}
\Css {body {margin-top: 100px;
                 margin-right: 400px;
                 margin-bottom: 10px;
                 margin-left: 400px;
  • 2
    Just to make sure your code isn't written in an unsual way, could you add the relevant lines of code to your question?
    – siracusa
    Jun 9, 2019 at 4:48
  • Sure, here's the code: $\hat{t}_c = \exp(y_c)/\sum \exp(y_l)$ and $E_c=0.5(\hat{t}_c- t_c)^2$
    – user62494
    Jun 9, 2019 at 17:04
  • I did try encapsulating the above in-line equations with \( ... \) and it looked better. Of course the issue in the OP only occured when I was outputting to html and using .svg images for equations. When I use \Preamble{xhtml, mathml} and comment out the .svg command, the issues in the OP don't arise. However, the summation symbols from \sum are very large in the output xhtml,mathml results(?)
    – user62494
    Jun 9, 2019 at 17:13
  • @4k3x9d7r try the pic-m option. it converts all inline math to pictures, which is better than the default method. other possible options are "mathjax" or "mathml,mathjax", which looks best in most circumstances, but requires JavaScript
    – michal.h21
    Jun 9, 2019 at 17:50
  • @michal.h21, thanks, see the modified post, since I added the preamble and command line that produced the best results I have seen thus far. FYI- I did change the .png equation images to .svg, since .png are hazy and low res. Do I want to use {xhtml,mathml} in the pre-amble or just {xhtml) -- which seems to do fine without mathml?
    – user62494
    Jun 9, 2019 at 18:16


You must log in to answer this question.