Welcome to pylatexenc’s documentation!

[pylatexenc version: 2.1]

A simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion.

Quick example:

>>> from pylatexenc.latex2text import LatexNodes2Text
>>> latex = r"""\textbf{Hi there!} Here is \emph{an equation}:
... \begin{equation}
...     \zeta = x + i y
... \end{equation}
... where $i$ is the imaginary unit.
... """
>>> print(LatexNodes2Text().latex_to_text(latex))
Hi there! Here is an equation:

    ζ = x + i y

where i is the imaginary unit.

And the other way around:

>>> from pylatexenc.latexencode import unicode_to_latex
>>> text = "À votre santé!"
>>> print(unicode_to_latex(text))
\`A votre sant\'e!

You can also use these utilities directly in command line, e.g.:

$ echo 'À votre santé!' | latexencode
\`A votre sant\'e!

Indices and tables