latex2sympy2
Convert latex to sympy with ANTLR and support Matrix, Linear Algebra and CAS functions.
What it is and what it does
latex2sympy2 is a LaTeX-to-SymPy converter that parses mathematical expressions written in LaTeX notation and translates them into SymPy's symbolic representation. It uses ANTLR to generate its parser and handles a broad range of mathematical constructs: basic arithmetic and functions, calculus operations (derivatives, integrals, limits), linear algebra (matrices, determinants, transposes, row/column operations), and special functions like trigonometric and logarithmic operations.
The package is designed for developers and educators who work with mathematical notation in LaTeX or Markdown and need to convert those expressions into executable symbolic math. It can both parse expressions into SymPy objects and convert them back to LaTeX form after calculation. The package maintains a variable store for tracking assigned values and supports complex number operations, making it useful for interactive math environments, VS Code extensions, and educational tools.
Use it for:
- Convert LaTeX derivatives and integrals to SymPy for symbolic computation and simplification.
- Parse matrix notation and perform elementary row/column transformations programmatically.
- Build interactive math calculators or educational tools that accept LaTeX input from users.
- Evaluate mathematical expressions written in LaTeX notation with variable substitution.
- Generate simplified LaTeX output after SymPy performs algebraic operations on parsed expressions.
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 matrix operations.
Yes, if you need LaTeX-to-SymPy conversion and can tolerate dormant maintenance. The package is stable, has no known vulnerabilities, and handles a comprehensive set of mathematical operations. However, be aware that the last release was in 2023 and there have been no recent commits, so bug fixes or updates for newer Python versions are unlikely. It is suitable for established use cases but not for projects requiring active upstream support.
Install
latex2sympy2 on PyPI
pip
pip install latex2sympy2uv
uv add latex2sympy2poetry
poetry add latex2sympy2Installing latex2sympy2
Before you install
Low install friction with only two runtime dependencies (sympy and antlr4-python3-runtime). However, the package is dormant—last release was 2023-04-23 and no commits since 2024-08-05, so maintenance support is limited.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute this package freely as long as you include the license notice.
Quickstart
from latex2sympy2 import latex2sympy, latex2latex
tex = r"\frac{d}{dx}(x^{2}+x)"
result = latex2sympy(tex)
# => "Derivative(x**2 + x, x)"
latex_result = latex2latex(tex)
# => "2 x + 1"
Verify before relying
- Whether determinant, transpose, and elementary transformation operations are suitable for production use given the documented irreversible calculations.
- Current compatibility with modern Python versions beyond those listed in classifiers (3.3–3.8).
- Whether the package handles edge cases and malformed LaTeX gracefully or raises exceptions.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — sympy, antlr4-python3-runtime |
| Maintenance | dormant — 1,209 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 538,617/month — #6,113 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: latex2sympy2-1.9.1-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
latex2sympy2-extendedParses LaTeX math expressions and converts them…
permissive · top 5,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
pylatexencConverts between LaTeX code and Unicode text in…
permissive · top 5,000 on PyPI
sphinx-math-dollarA Sphinx extension that lets you write LaTeX…
permissive · top 15,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
python-markdown-mathAdds support for rendering mathematical…
permissive · top 15,000 on PyPI