Ziamath

Ziamath renders MathML or LaTeX Math expressions as SVG paths using only the Python standard library. Does not require a Latex installation, nor rely on any third party services, but rather uses math-enabled fonts, such as STIXTwoMath-Regular which comes included with Ziamath for use by default. The resulting SVGs are drawn entirely with <path> elements, so the image does not depend on having the font available.

Example

To render from MathML:

import ziamath as zm
zm.Math(
'''<mrow>
     <mi> y </mi>
     <mo> = </mo>
     <mi> f </mi>
     <mo> &ApplyFunction; </mo>
     <mrow>
       <mo> ( </mo>
       <mi> x </mi>
       <mo> ) </mo>
     </mrow>
   </mrow>''')
_images/index_0_0.svg

To render from Latex:

zm.Math.fromlatex(r'\frac{1}{1-x^2}')
_images/index_1_0.svg

Support

If you appreciate Ziamath, buy me a coffee to show your support!



Source code is available on Bitbucket.

Ziamath is also used by the Ziaplot and Schemdraw Python packages, and was used for rendering the SVG and PNG equations on MathGrabber.