Pure Python library for LaTeX to MathML conversion
Project description
latex2mathml
Pure Python library for LaTeX to MathML conversion
| License | Version | ||
| Travis CI | Coverage | ||
| AppVeyor | Supported versions | ||
| Wheel | Implementation | ||
| Status | Downloads |
Installation
pip install latex2mathml
Usage
import latex2mathml.converter
latex_input = "<your_latex_string>"
mathml_output = latex2mathml.converter.convert(latex_input)
Demo
Examples
Identifiers, Numbers and Operators
| LaTeX Input | MathML Output |
|---|---|
x |
<math>
<mrow>
<mi>x</mi>
</mrow>
</math>
|
xyz |
<math>
<mrow>
<mi>x</mi>
<mi>y</mi>
<mi>z</mi>
</mrow>
</math>
|
3 |
<math>
<mrow>
<mn>3</mn>
</mrow>
</math>
|
444 |
<math>
<mrow>
<mn>444</mn>
</mrow>
</math>
|
12.34 |
<math>
<mrow>
<mn>12.34</mn>
</mrow>
</math>
|
12x |
<math>
<mrow>
<mn>12</mn>
<mi>x</mi>
</mrow>
</math>
|
3-2 |
<math>
<mrow>
<mn>3</mn>
<mo>−</mo>
<mn>2</mn>
</mrow>
</math>
|
Subscripts and Superscripts
| LaTeX Input | MathML Output |
|---|---|
a_b |
<math>
<mrow>
<msub>
<mi>a</mi>
<mi>b</mi>
</msub>
</mrow>
</math>
|
a^b |
<math>
<mrow>
<msup>
<mi>a</mi>
<mi>b</mi>
</msup>
</mrow>
</math>
|
a_b^c |
<math>
<mrow>
<msubsup>
<mi>a</mi>
<mi>b</mi>
<mi>c</mi>
</msubsup>
</mrow>
</math>
|
Fractions
| LaTeX Input | MathML Output |
|---|---|
\frac{1}{2} |
<math>
<mrow>
<mfrac>
<mrow>
<mn>1</mn>
</mrow>
<mrow>
<mn>2</mn>
</mrow>
</mfrac>
</mrow>
</math>
|
Roots
| LaTeX Input | MathML Output |
|---|---|
\sqrt{2} |
<math>
<mrow>
<msqrt>
<mrow>
<mn>2</mn>
</mrow>
</msqrt>
</mrow>
</math>
|
\sqrt[3]{2} |
<math>
<mrow>
<mroot>
<mrow>
<mn>2</mn>
</mrow>
<mrow>
<mn>3</mn>
</mrow>
</mroot>
</mrow>
</math>
|
Matrices
| LaTeX Input | MathML Output |
|---|---|
\begin{matrix}a & b \\ c & d \end{matrix} |
<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>
|
\begin{matrix*}[r]a & b \\ c & d \end{matrix*} |
<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>
|
A_{m,n} =
\begin{bmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{bmatrix}
|
<math>
<mrow>
<msub>
<mi>A</mi>
<mrow>
<mi>m</mi>
<mi>,</mi>
<mi>n</mi>
</mrow>
</msub>
<mo>=</mo>
<mo>[</mo>
<mtable>
<mtr>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mn>1</mn>
<mi>,</mi>
<mn>1</mn>
</mrow>
</msub>
</mtd>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mn>1</mn>
<mi>,</mi>
<mn>2</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mo>⋯</mo>
</mtd>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mn>1</mn>
<mi>,</mi>
<mi>n</mi>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mn>2</mn>
<mi>,</mi>
<mn>1</mn>
</mrow>
</msub>
</mtd>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mn>2</mn>
<mi>,</mi>
<mn>2</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mo>⋯</mo>
</mtd>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mn>2</mn>
<mi>,</mi>
<mi>n</mi>
</mrow>
</msub>
</mtd>
</mtr>
<mtr>
<mtd>
<mo>⋮</mo>
</mtd>
<mtd>
<mo>⋮</mo>
</mtd>
<mtd>
<mo>⋱</mo>
</mtd>
<mtd>
<mo>⋮</mo>
</mtd>
</mtr>
<mtr>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mi>m</mi>
<mi>,</mi>
<mn>1</mn>
</mrow>
</msub>
</mtd>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mi>m</mi>
<mi>,</mi>
<mn>2</mn>
</mrow>
</msub>
</mtd>
<mtd>
<mo>⋯</mo>
</mtd>
<mtd>
<msub>
<mi>a</mi>
<mrow>
<mi>m</mi>
<mi>,</mi>
<mi>n</mi>
</mrow>
</msub>
</mtd>
</mtr>
</mtable>
<mo>]</mo>
</mrow>
</math>
|
References
LaTeX
- https://en.wikibooks.org/wiki/LaTeX/Mathematics
- http://artofproblemsolving.com/wiki/index.php?title=Main_Page
- http://milde.users.sourceforge.net/LUCR/Math/
- http://www.forkosh.com/mimetextutorial.html
MathML
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
latex2mathml-2.8.5.tar.gz
(63.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latex2mathml-2.8.5.tar.gz.
File metadata
- Download URL: latex2mathml-2.8.5.tar.gz
- Upload date:
- Size: 63.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.6.7 Linux/4.15.0-1028-gcp
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51fe3d94db030e2c8eec59c1f74cb5641acc61513c6a7a53f774a1d771e1c8a3
|
|
| MD5 |
5015ca1274a0d0fb12a20fd9b0f57e6c
|
|
| BLAKE2b-256 |
4e8462983425ab9ec78b227e37e8102eb5a7e86ed9e0a2cde77bc1633f4e1ec5
|
File details
Details for the file latex2mathml-2.8.5-py3-none-any.whl.
File metadata
- Download URL: latex2mathml-2.8.5-py3-none-any.whl
- Upload date:
- Size: 63.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.6.7 Linux/4.15.0-1028-gcp
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da939460a7c7d5f1433bd37957bbe4ea93f03dc1ab3b241525f7022bca09085
|
|
| MD5 |
df51d39dc51630e84103792c038b4168
|
|
| BLAKE2b-256 |
0a068448106681dd1802f8f288730786ef5b30586956acc46387b4ab6ecf8c10
|