Skip to content

Parse LaTeX math expressions

License

Notifications You must be signed in to change notification settings

ConsoleBit/latex2sympy

 
 

Repository files navigation

latex2sympy

latex2sympy parses LaTeX math expressions and converts it into the equivalent SymPy form.

Installation

ANTLR is used to generate the parser:

antlr-4.7.2-complete.jar PS.g4 -o gen

or

java -jar antlr-4.7.2-complete.jar PS.g4 -o gen

Usage

In Python 2.7:

from latex2sympy import process_sympy

process_sympy("\\frac{d}{dx} x^{2}")
# => "diff(x**(2), x)"

Examples

LaTeX Image Generated SymPy
x^{3} x**3
`\frac{d}{dx} t x`
\sum_{i = 1}^{n} i Sum(i, (i, 1, n))
\int_{a}^{b} \frac{dt}{t} Integral(1/t, (t, a, b))
`(2x^3 - x + z) _{x=3}`

Contributing

Contributors are welcome! Feel free to open a pull request or an issue.

About

Parse LaTeX math expressions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.9%
  • ANTLR 2.7%
  • Shell 0.4%