When compiling the following document with htlatex test.tex "xhtml,mathml" the generated HTML document contains an unencoded < in the alt attribute of the image which is not XML standard-compliant.

What can I add to the configuration file to make htlatex correctly encode < as &lt; in the alt attributes?


The body of the generated html document is (with a bit of formatting):

<p class="noindent" >
 <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline" >
  <img src="test0x.png" alt="<mi>P</mi><mi>I</mi><mi>C</mi>" class="pspicture" />
  • @DavidCarlisle it is generating mathml, but the pspicture inside math is generating image. The PIC alt text is then converted to mathml.
    – michal.h21
    Commented Mar 5, 2017 at 13:15

1 Answer 1


Default alt text, PIC, is produced when pspicture is converted to image. Because you use it inside math, this alt text is treated as math text and each character is surrounded by <mi> element. We have two options - to put the alt text inside \HCode command, which will block the processing the text to mathml, or to remove it completely.

There is a special configuration for pspicture alt text, pspictureAlt. You can try the following configuration file:


\Configure{pspictureAlt}{\HCode{pspicture figure}}

I noticed also another issue when I compiled your code: the pstricks to png failed with errors. I tried dvipng and dvips -> ghostscript. Only dvisvgm seems to work. If you use updated TL 2016 distribution, you can request dvisvgm compilation if you add the following line the the configuration file:


You can compile your document using:

make4ht -um draft -c configfilename.cfg test.tex

And this is the result:

<!--l. 4--><p class="noindent" ><!--l. 4--><math 
display="inline" ><!--width="22.76227pt" height="28.45274pt"--><img 
src="sample0x.svg" alt="pspicture figure" class="pspicture" /></math>

enter image description here


You must log in to answer this question.

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