skillfed

latex2sympy2

Convert latex to sympy with ANTLR and support Matrix, Linear Algebra and CAS functions.

latex2sympy2 v1.9.1 538.6K downloads/30d#6,113 on PyPI148
Permissive license MIT DORMANT released

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 latex2sympy2

uv

uv add latex2sympy2

poetry

poetry add latex2sympy2

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: EducationTopic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: CompilersTopic :: Text Processing :: Markup :: LaTeXTopic :: Text Processing :: Markup :: Markdown

Tags

latex to sympy conversionparse latex math expressionslatex equation parsersymbolic math from latexlatex to python mathantlr latex parserlatex formula interpreter
latex-parsingsymbolic-mathantlr

More Mathematics packages