[Tex/LaTex] Sphinx in-line math equation alignment

formattingsphinxtools

As suggested by the answer to my question here, I am using the Sphinx tool in order to multi-target PDF and HTML output. For HTML, I'm using the pngmath extension.

The vertical alignment of inline math in the HTML output is very bothersome. The math equations are positioned below where they should and this causes the entire rendered page to look bad because none of the equations are lined-up properly.

Does anyone know how this can be fixed?

Best Answer

See my question about exactly that, in short the solution is to add to conf.py:

pngmath_latex_preamble=r'\usepackage[active]{preview}' # + other custom stuff for inline math, such as non-default math fonts etc.
pngmath_use_preview=True

This "feature" is explained in sphinx docs.