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", encoding="utf-8").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
mathra.render("sqrt(x)/2", input="asciimath")["speech"]                   # also input="mathml"
tex_to_svg(tex, locale="en", *, display=True, strict=False, input="latex", braille=None) The SVG as a string.
render(tex, locale="en", *, display=True, strict=False, input="latex", braille=None) A dict: svg, speech, text, braille, braille_code, tree, applied, warnings.
tex_to_tree(tex, locale="en", *, display=True, strict=False, input="latex", braille=None) 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.

input is "latex", "mathml" or "asciimath"; MathML passed as LaTeX, starting with <math, is recognized on its own. braille is "cmu" or "nemeth"; by default the locale's (CMU in pt-BR and es, Nemeth elsewhere). 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 equation 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.3.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.3.0
File Size Uploaded Provenance Actions
mathra-1.3.0.tar.gz 1.3 MB With provenance Details for mathra-1.3.0.tar.gz

Built distributions (wheels)

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

Total release size: 9.2 MB

Release files / mathra-1.3.0.tar.gz

Download URL mathra-1.3.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
fc142d51e19ecf1aa28277b63eaee7e4c45c050e04e5983db40ab6b529808b9e
BLAKE2b-256 checksum
How to use checksums
9b1b5f902e08af729ef163217de6f02a81b557ea2bb449e9eab5eb5fbaf1a2f5
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 25, 2026.

Transparency log

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

Download URL mathra-1.3.0-cp39-abi3-win_amd64.whl
Size 1.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
210c0eb5d824984349f130fe638c0789ab292d014fdeef77eb3241b6b9aa7b74
BLAKE2b-256 checksum
How to use checksums
dbeb5bfc4b04fa989f76a10fbceead3531066e3735f388870a683d6102b01064
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 25, 2026.

Transparency log

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

Download URL mathra-1.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
672b365437432347253f57df1cbe2b98634d922aeb4004f2d96d6e72eac4946b
BLAKE2b-256 checksum
How to use checksums
a81de88fcf9c982be1ff69a15134f244347d90a7db1ac91257c17f4668488245
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 25, 2026.

Transparency log

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

Download URL mathra-1.3.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.6 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
0b5e42371b17633f02d626c984b32e8a0dca2eccc198b8aa20b3c13195ccf780
BLAKE2b-256 checksum
How to use checksums
38cb5dd1d2f90ef28455ee6ef6cec06b4ec2ef9b874bda5d02472bf55a5a6af3
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 25, 2026.

Transparency log

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

Download URL mathra-1.3.0-cp39-abi3-macosx_11_0_arm64.whl
Size 1.6 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3ed691f4d931da444d961db8fe2ac4d59f1845cb36fcfd995c859c05f1bd15c7
BLAKE2b-256 checksum
How to use checksums
18a2b35ecef5ad05ba96a3caf1d5b931a8a508403b32bd181016758134a86d38
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 25, 2026.

Transparency log

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

Download URL mathra-1.3.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
49448468a57eb0e2c25fef6d3dcaf706287031ecaa6be306d519a6b2f4ee8441
BLAKE2b-256 checksum
How to use checksums
658ab59424b26846a2bd3ce5a67e28006f67adbf39c60f7de902f61224ae95cf
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 25, 2026.

Transparency log

Security for mathra 1.3.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.3.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 25, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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