Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Pure Python library for LaTeX to MathML conversion.

Project description

Pure Python library for LaTeX to MathML conversion.

Demo

latex2mathml Demo

*Tested in Firefox only

Examples

Identifiers, Numbers and Operators

LaTeX Input

x

MathML Output

<math>
    <mrow>
        <mi>
            x
        </mi>
    </mrow>
</math>

LaTeX Input

xyz

MathML Output

<math>
    <mrow>
        <mi>
            x
        </mi>
        <mi>
            y
        </mi>
        <mi>
            z
        </mi>
    </mrow>
</math>

LaTeX Input

3

MathML Output

<math>
    <mrow>
        <mn>
            3
        </mn>
    </mrow>
</math>

LaTeX Input

444

MathML Output

<math>
    <mrow>
        <mn>
            444
        </mn>
    </mrow>
</math>

LaTeX Input

12.34

MathML Output

<math>
    <mrow>
        <mn>
            12.34
        </mn>
    </mrow>
</math>

LaTeX Input

12x

MathML Output

<math>
    <mrow>
        <mn>
            12
        </mn>
        <mi>
            x
        </mi>
    </mrow>
</math>

LaTeX Input

3-2

MathML Output

<math>
    <mrow>
        <mn>
            3
        </mn>
        <mo>
            &#x02212;
        </mo>
        <mn>
            2
        </mn>
    </mrow>
</math>

Subscripts and Superscripts

LaTeX Input

a_b

MathML Output

<math>
    <mrow>
        <msub>
            <mi>
                a
            </mi>
            <mi>
                b
            </mi>
        </msub>
    </mrow>
</math>

LaTeX Input

a^b

MathML Output

<math>
    <mrow>
        <msup>
            <mi>
                a
            </mi>
            <mi>
                b
            </mi>
        </msup>
    </mrow>
</math>

LaTeX Input

a_b^c

MathML Output

<math>
    <mrow>
        <msubsup>
            <mi>
                a
            </mi>
            <mi>
                b
            </mi>
            <mi>
                c
            </mi>
        </msubsup>
    </mrow>
</math>

Fractions

LaTeX Input

\frac{1}{2}

MathML Output

<math>
    <mrow>
        <mfrac>
            <mrow>
                <mn>
                    1
                </mn>
            </mrow>
            <mrow>
                <mn>
                    2
                </mn>
            </mrow>
        </mfrac>
    </mrow>
</math>

Roots

LaTeX Input

\sqrt{2}

MathML Output

<math>
    <mrow>
        <msqrt>
            <mrow>
                <mn>
                    2
                </mn>
            </mrow>
        </msqrt>
    </mrow>
</math>

LaTeX Input

\sqrt[3]{2}

MathML Output

<math>
    <mrow>
        <mroot>
            <mrow>
                <mn>
                    2
                </mn>
            </mrow>
            <mrow>
                <mn>
                    3
                </mn>
            </mrow>
        </mroot>
    </mrow>
</math>

Matrices

LaTeX Input

\begin{matrix}a & b \\ c & d \end{matrix}

MathML Output

<math>
    <mrow>
        <mtable>
            <mtr>
                <mtd>
                    <mi>
                        a
                    </mi>
                </mtd>
                <mtd>
                    <mi>
                        b
                    </mi>
                </mtd>
            </mtr>
            <mtr>
                <mtd>
                    <mi>
                        c
                    </mi>
                </mtd>
                <mtd>
                    <mi>
                        d
                    </mi>
                </mtd>
            </mtr>
        </mtable>
    </mrow>
</math>

LaTeX Input

\begin{matrix*}[r]a & b \\ c & d \end{matrix*}

MathML Output

<math>
    <mrow>
        <mtable>
            <mtr>
                <mtd columnalign='right'>
                    <mi>
                        a
                    </mi>
                </mtd>
                <mtd columnalign='right'>
                    <mi>
                        b
                    </mi>
                </mtd>
            </mtr>
            <mtr>
                <mtd columnalign='right'>
                    <mi>
                        c
                    </mi>
                </mtd>
                <mtd columnalign='right'>
                    <mi>
                        d
                    </mi>
                </mtd>
            </mtr>
        </mtable>
    </mrow>
</math>

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
latex2mathml-1.0.7.zip (62.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page