https://github.com/augustt198/latex2sympy
Parse LaTeX math expressions
https://github.com/augustt198/latex2sympy
Last synced: 5 months ago
JSON representation
Parse LaTeX math expressions
- Host: GitHub
- URL: https://github.com/augustt198/latex2sympy
- Owner: augustt198
- License: mit
- Archived: true
- Created: 2016-01-10T16:30:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-11T11:55:57.000Z (almost 6 years ago)
- Last Synced: 2024-08-03T01:26:27.568Z (9 months ago)
- Language: Python
- Homepage:
- Size: 46.9 KB
- Stars: 386
- Watchers: 24
- Forks: 162
- Open Issues: 31
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-rainmana - augustt198/latex2sympy - Parse LaTeX math expressions (Python)
README
# latex2sympy
latex2sympy parses LaTeX math expressions and converts it into the
equivalent SymPy form.## Installation
[ANTLR](http://www.antlr.org/) is used to generate the parser:
```
$ antlr4 PS.g4 -o gen
```## Usage
In Python 2.7:
```python
from process_latex import process_sympyprocess_sympy("\\frac{d}{dx} x^{2}")
# => "diff(x**(2), x)"
```## Examples
|LaTeX|Image|Generated SymPy|
|-----|-----|---------------|
|`x^{3}`|| `x**3`|
|`\frac{d}{dx} |t|x`||`Derivative(x*Abs(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}`||`z + 51`## Contributing
Contributors are welcome! Feel free to open a pull request
or an issue.