Skip to main content

mathra

mathra

Math LaTeX to accessible SVG, without a TeX install. Every SVG carries the phrase a screen reader says, in 16 languages, and draws with the STIX Two Math font embedded, so it looks the same everywhere. Try it in the browser.

pip install mathra

Wheels for Linux, macOS and Windows, for Python 3.9 and later; nothing else to install.

Usage

import mathra

svg = mathra.tex_to_svg(r"x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}")
open("quadratic.svg", "w").write(svg)

r = mathra.render(r"\frac{3}{4}", locale="fr")
r["speech"]        # 'trois quarts'
r["warnings"]      # [] — broken LaTeX is drawn anyway and reported here (E-REC-*)

mathra.tex_to_svg(r"\sum_{n=1}^{\infty} \frac{1}{n^2}", display=False)   # inline style
mathra.tex_to_svg(r"\vertA\vert", strict=True)                           # ValueError, like TeX
tex_to_svg(tex, locale="en", *, display=True, strict=False) The SVG as a string.
render(tex, locale="en", *, display=True, strict=False) A dict: svg, speech, text, tree, applied, warnings.
tex_to_tree(tex, locale="en", *, display=True, strict=False) The tree of meaning as JSON.
locales() [{"code": "en", "name": "English"}, …]: en, pt-BR, es, fr, de, it, ru, zh, ja, ko, hi, ar, id, tr, nl, pl.

Errors are ValueError. Types are included (py.typed).

What it draws

Every image below is an SVG written by mathra, on a white card so it reads well on dark pages.

Quadratic formula
Quadratic formula
Gaussian integral
Gaussian integral
m × n matrix with dots
Matrix with dots
Piecewise definition
Piecewise definition
Chemical equation (mhchem)
Chemistry (\ce)
Quantity with units (siunitx)
Units (\SI)
Maxwell's equations
Maxwell's equations

What the SVG carries

Speech in <title> linked with aria-labelledby, the source LaTeX and the tree of meaning in <metadata>, color from the page (currentColor), size in em, a selectable text layer and ids unique to each equation. The same input always gives the same bytes, in Python and in every other package.

Also for JavaScript, Rust and the terminal

The same core is an npm package (@mathlabs/mathra), a Rust crate and a command-line tool: github.com/matheusmota-dev-br/mathra. Rules, languages and the full list of supported commands are there too.

License

The code is MIT or Apache-2.0; the embedded STIX Two Math font is under the SIL Open Font License 1.1.

Metadata

Release files for mathra 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mathra 1.0.0
File Size Uploaded Provenance
mathra-1.0.0.tar.gz 769.0 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for mathra 1.0.0
File
mathra-1.0.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
mathra-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
mathra-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
mathra-1.0.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
mathra-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 7.4 MB

Release files / mathra-1.0.0.tar.gz

Download URL mathra-1.0.0.tar.gz
Size 769.0 kB
Tags Source
SHA-256 checksum
How to use checksums
085ef2f5c230fe9007cda594fdd40c793cff8448c27bf2071057f117f8b91755
BLAKE2b-256 checksum
How to use checksums
55e612540e51f1c49054798a57f9066adf17a7af1552e6ead78d86edbcf27a99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / mathra-1.0.0-cp39-abi3-win_amd64.whl

Download URL mathra-1.0.0-cp39-abi3-win_amd64.whl
Size 1.2 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f868c88a5235e6dff5e85992458cf1ee412ce7b0b410d212fd7a2669076e83fb
BLAKE2b-256 checksum
How to use checksums
a684f371e05be9b7fea7863237a9902d9e6bca5f88ecb2a75590b4c533e59ad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / mathra-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mathra-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
29c54d850209a3ecd59eefac72154ade1477946074e744233a3a827820415174
BLAKE2b-256 checksum
How to use checksums
088209e5216a818df84791bf35e40bc317403651b7799ba3df911e777e2e9335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / mathra-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mathra-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.4 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4ae2de4b5a8c77091756a3dce634c8cb2a0d64dcf4b3aa2a65e9534d0dabfd75
BLAKE2b-256 checksum
How to use checksums
24d654764313f37509ee1cb719a47e31496a4011123bd13441139e6c14b0a1c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / mathra-1.0.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL mathra-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
Size 1.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
00facb9d8eba1296abec526787f2d155404b88503096b74cf7fbfd1be855ef3d
BLAKE2b-256 checksum
How to use checksums
ba92f65db0671ddada8fe760d0e21e4a4122b066c35f7f3bfafc6b37e1c83fda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / mathra-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL mathra-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 1.3 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3560f75aad5de936cba1ec6628678a38a7a9e11fe9126e6c50a75127f000ad87
BLAKE2b-256 checksum
How to use checksums
f414d5f37d15759fa8c60f922cb5fbd2d626b632543647ce72ff01404de6ef33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for mathra 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for mathra-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page