Ziamath

Ziamath renders MathML or LaTeX Math expressions as SVG paths. 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

Installation

Ziamath can be installed using pip:

pip install ziamath

Ziamath natively draws MathML. For Latex support, the latex2mathml package is used to convert the Latex into MathML first. It can be installed along with ziamath:

pip install ziamath[latex]

Ziamath depends on its sister package, Ziafont, for reading TTF font files.