latex2sympy2-extended
Convert LaTeX math to SymPy expressions
What it is and what it does
latex2sympy2_extended is a LaTeX-to-SymPy parser that reads mathematical notation in LaTeX format and produces equivalent SymPy symbolic expressions. It uses ANTLR 4.13.1 to generate its parser and handles a broad range of mathematical constructs: basic arithmetic and functions, calculus operations like derivatives and integrals, linear algebra including matrices and determinants, and set operations. The package is adapted from an earlier latex2sympy project and supports multiple ANTLR runtime versions.
The typical workflow is to pass a LaTeX string to the main `latex2sympy()` function, which returns a SymPy expression you can then manipulate, evaluate, or further process in Python. It handles subscripts, Greek letters, common mathematical functions, and complex expressions with nested operations. One important caveat: operations on determinants, transposed matrices, and elementary row/column transformations perform actual symbolic computation and are not reversible—the result is simplified rather than left as a structural representation.
Use it for:
- Convert handwritten or scanned LaTeX math formulas into SymPy for symbolic computation and manipulation.
- Parse mathematical expressions from documents or user input to enable programmatic solving and evaluation.
- Automate derivation and integration workflows by converting LaTeX calculus notation to SymPy Derivative and Integral objects.
- Transform matrix notation from LaTeX into SymPy Matrix objects for linear algebra operations.
- Build educational tools or math tutoring systems that accept LaTeX input and perform symbolic analysis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses LaTeX math expressions and converts them to SymPy symbolic form, supporting arithmetic, functions, calculus, linear algebra, and set operations.
Yes, if you need to parse LaTeX math into SymPy. The package has low install friction, permissive licensing, no known vulnerabilities, and solid popularity (top 5000). The aging maintenance status (216 days since last release) is a minor concern for a parser—grammar-based tools are relatively stable—but verify that the ANTLR runtime version you choose aligns with your environment. Suitable for production use in math-heavy applications.
Install
latex2sympy2-extended on PyPI
pip
pip install latex2sympy2-extendeduv
uv add latex2sympy2-extendedpoetry
poetry add latex2sympy2-extendedInstalling latex2sympy2-extended
Before you install
Low install friction with only two runtime dependencies (sympy and antlr4-python3-runtime). Package is aging—last release was 216 days ago—so expect slower response to issues, though no active maintenance problems are evident.
License in practice
MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions.
Quickstart
pip install latex2sympy2-extended
from latex2sympy2_extended import latex2sympy
tex = r"\frac{d}{dx}(x^{2}+x)"
result = latex2sympy(tex)
# => "Derivative(x**2 + x, x)"
Requires Python 3.10 or later.
Verify before relying
- Whether determinant, transpose, and elementary transformation calculations are truly irreversible in all use cases or only under specific conditions.
- Performance characteristics with large or deeply nested LaTeX expressions.
- Completeness of support for less common LaTeX math environments beyond those documented in examples.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — sympy, antlr4-python3-runtime |
| Maintenance | aging — 216 days since the last release |
| First released | |
| Downloads | 3,417,128/month — #2,628 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: latex2sympy2_extended-1.11.0-py3-none-any.whl
Tags
More Mathematics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
sympySymPy is a Python library for symbolic…
permissive · top 1,000 on PyPI
contourpyContourPy calculates contours of 2D…
permissive · top 1,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
onnxruntimeonnxruntime loads and executes Open Neural…
permissive · top 1,000 on PyPI
latex2sympy2Parses LaTeX math expressions and converts them…
permissive · top 15,000 on PyPI
math-verifyEvaluates mathematical expressions from LLM…
permissive · top 5,000 on PyPI
py-asciimathConverts between ASCIIMath, LaTeX, and MathML…
permissive · top 5,000 on PyPI
sphinx-math-dollarA Sphinx extension that lets you write LaTeX…
permissive · top 15,000 on PyPI
pylatexencConverts between LaTeX code and Unicode text in…
permissive · top 5,000 on PyPI
sphinxcontrib-katexA Sphinx extension that renders mathematical…
permissive · top 15,000 on PyPI
pysrPySR searches for symbolic expressions that fit…
permissive · top 15,000 on PyPI
latex2mathmlConverts LaTeX mathematical expressions to…
permissive · top 5,000 on PyPI
py-expression-evalParses and evaluates mathematical expressions…
permissive · top 15,000 on PyPI