I am trying to convert document to HTML with MathML rendered by MathJax (the reason is that pure mathjax output does not do proper equation numbering). Unfortunately, I get all the capital greek letters in formulas in italic font, while they clearly should be upright (as formatted by normal TeX).

That is, the test document


which is compiled with

make4ht -u test 'html,mathml,mathjax'

Gives the output that looks like

enter image description here

While I would clearly prefer the original LaTeX formatting

enter image description here

As for now, I can get the proper formula in two cases:

make4ht -u test 'html'

which inserts PNG image of the formula -- not at all what I would like to look nice on screen. Other way

make4ht -u test 'html,mathjax'

This one looks nice (proper resolution/browser independent formatting by MathJax), but fails on documents with equation numbering.

I would be glad to have suggestions!

  • Correction taken. By 'proper MathJax' I meant that it looks nice on screen :) Rendered in a resolution and browser independent way by MathJax. The problem here is that MathJax does not have a very good way to render the equation numbers. Actually, it has, but tex4ht with 'mathjax' output format fails to feed mathjax the equation numbers in a proper way, while 'mathml,mathjax' formats the equation numbers correctly. Probably, fixing the mathjax.4ht to deal with equation numbers using mathjax tagformat is the best solution, but my fisrt hope was to evade coding the better translator :)
    – Fedxa
    Commented Apr 29, 2021 at 22:43

1 Answer 1


You can try this .cfg file:

\def\temp#1#2{\def#1{\PauseMathClass{\HCode{<mi mathvariant="normal">}\special{t4ht@+\string&{35}x#2{59}}x\HCode{</mi>}}\EndPauseMathClass}}

It redefines \Psi and other problematic programs to output <mi mathvariant="normal">Ψ</mi>. The mathvariant="normal" attribute is necessary in order to display Psi as upright text. TeX4ht produces by default just <mi> element, without this attribute. <mi> elements that contain just single letter are displayed in italics by MathML, so it is necessary to use the mathvariant attribute. The \special command uses TeX4ht DVI processing instructions to output Unicode codepoint of Psi. \PauseMathClass disables the normal TeX4ht font processing, we need this in order to prevent some additional tags be written.

This is the result:

enter image description here

  • Great, gets me closer to the solution. Putting your text (with added closing }) into test.cfg and running make4ht test 'test,mathml,mathjax' gives in the output something like <mi mathvariant="normal"><mi >&#x03A8;</mi></mi>. If it is compiled only with mathml then firefox dsiplays it correctly. MathJax fails -- the 'inside' <mi> misleds it. Any way to prevent the double <mi> tag?
    – Fedxa
    Commented Apr 29, 2021 at 22:31
  • @Fedxa you are right, I've posted an updated cfg file that should work better and also support other simillar commands.
    – michal.h21
    Commented Apr 29, 2021 at 22:39
  • Great! That one reproduces properly the original TeX formatting. Do you think it should make it to the default mathml.ht4? I agree, that upright caputal greek fonts is a legacy, but consistency of formatting is probably more important...
    – Fedxa
    Commented Apr 29, 2021 at 22:54
  • Ups, the updated file fails on $\Psi_x$... Produces <mi mathvariant="normal"><msub><mrow >&#x03A8;</mi></mrow><mrow ><mi >x</mi></mrow></msub >
    – Fedxa
    Commented Apr 29, 2021 at 23:10
  • Oh, adding an extra pair of '{}' in the def command made the code robust. Will add the fully working solution to my post later today. Thank you @michal.h21 !
    – Fedxa
    Commented Apr 30, 2021 at 8:34

You must log in to answer this question.

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