This is a Python library for parsing mathematical expressions and converting them to LaTeX format. The library provides classes for representing mathematical expressions and LaTeX elements, as well as a parser for converting mathematical expressions to LaTeX. This library was primarily developed to translate symbolic expressions obtained from symbolic expression with MATLAB, but it can be adapted to translate other expressions as well.
- Translate a simple text expression to a latex expression
- Translate multiple text expression to a latex expression in an array (under development)
To install the library, clone the repository and install it:
git clone https://github.com/yourusername/latex-expression-parser.git
cd latex-expression-parser
pip install .
If you want to install it and still be able to change the source code without re-installing it after each modification, change the last command to the following:
pip install -e .
Their is multiple ways to use this librairy, depending on the use case. You can either:
You can use it directly in the command windows:
txt2latex translate --help
Or as a python module:
python -m txt2latex --help
You can import it in a python script and use it's functionality
expression = r"a + (p^2 + 2*omega*(b - c))*(p^3 - (a*p^2)*(c - d) - a)"
from txt2latex import parsers
logic_expr = parsers.parse_txt_expression(expression)
latex_expr = parsers.parse_logical_expression(logic_expr)
print(latex_expr)
The application is a module in itself, but contains different submodule and sub-directory. These main components are:
scripts/
: A sub-directory containing the scripts used for the principals functionality of the module. It contains the following scripts:translate.py
: translate an expressiontests.py
: execute the testsoperator.py
: handles the operators used for the translation (under developpment)
src/
: A sub-directory containing the source code of the application. It contain the following submodule:baseComponents
: containing the class definitions of the main class used by the applicationparsers
: containing the function used for parsing expressions (under development)configParser
: containing a helper class representing a config file (under development)logueur
: containg a helper class for logging message to the console (under development)
Contributions are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository. If you would like to contribute code, please fork the repository and submit a pull request.