Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion

https://img.shields.io/github/license/phfaist/pylatexenc.svg?style=flat https://img.shields.io/pypi/v/pylatexenc.svg?style=flat

Python: ≥ 3.6. The library has no runtime dependencies and is designed to be as backwards-compatible as reasonably possible.

PYLATEXENC 3.0beta is in pre-release on PyPI. Try pip install --pre pylatexenc. See new features and major changes. The documentation is still incomplete, and the new APIs are still subject to changes. The code is meant to be as backwards compatible as is reasonably possible. Feel free to try it out & submit feedback!

Unicode Text to LaTeX code

The pylatexenc.latexencode module provides a function unicode_to_latex() which converts a unicode string into LaTeX text and escape sequences. It should recognize accented characters and most math symbols. A couple of switches allow you to alter how this function behaves.

You can also run latexencode in command-line to convert plain unicode text (from the standard input or from files given on the command line) into LaTeX code, written on to the standard output.

A third party plug-in for Vim vim-latexencode by @Konfekt provides a corresponding command to operate on a given range.

Parsing LaTeX code & converting to plain text (unicode)

The pylatexenc.latexwalker module provides a series of routines that parse the LaTeX structure of given LaTeX code and returns a logical structure of objects, which can then be used to produce output in another format such as plain text. This is not a replacement for a full (La)TeX engine, rather, this module provides a way to parse a chunk of LaTeX code as mark-up code.

The pylatexenc.latex2text module builds up on top of pylatexenc.latexwalker and provides functions to convert given LaTeX code to plain text with unicode characters.

You can also run latex2text in command-line to convert LaTeX input (either from the standard input, or from files given on the command line) into plain text written on the standard output.

Documentation

Full documentation is available at https://pylatexenc.readthedocs.io/.

To build the documentation manually, run:

> uv sync --group builddoc
> cd doc/
doc> uv run make html

License

See LICENSE.txt (MIT License).

NOTE: See copyright notice and license information for file tools/unicode.xml provided in tools/unicode.xml.LICENSE. (The file tools/unicode.xml was downloaded from https://www.w3.org/2003/entities/2007xml/unicode.xml as linked from https://www.w3.org/TR/xml-entity-names/#source.)

Javascript Library

Some core parts of this library can be transcribed to JavaScript. This feature is used (and was developed for) my Flexible Latex-like Markup project. See the js-transcrypt/ folder and its README file.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylatexenc-3.0b2.tar.gz (260.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylatexenc-3.0b2-py3-none-any.whl (322.3 kB view details)

Uploaded Python 3

File details

Details for the file pylatexenc-3.0b2.tar.gz.

File metadata

  • Download URL: pylatexenc-3.0b2.tar.gz
  • Upload date:
  • Size: 260.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pylatexenc-3.0b2.tar.gz
Algorithm Hash digest
SHA256 14c6148c3cabebaff5e488e304abb21024f86fdab7d70bafc9f29d62463a7d9d
MD5 5aaf3f76684fd8a86e20b3723bea7d47
BLAKE2b-256 205168a89d104d9b892bf459912367256b1c5222aca544f655303a1981d94755

See more details on using hashes here.

File details

Details for the file pylatexenc-3.0b2-py3-none-any.whl.

File metadata

  • Download URL: pylatexenc-3.0b2-py3-none-any.whl
  • Upload date:
  • Size: 322.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.33 {"installer":{"name":"uv","version":"0.11.33","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pylatexenc-3.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 0cd14a2104ec4eaeaaadcab85b2da8c183a5feb39d71301a4db9d033b3e6e349
MD5 2ecc8405080c5ded2c137bebf56f2b98
BLAKE2b-256 b3f944351165a7f14073e75825769fd1aec61d1da944b61a7296725cc95ff889

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.0b2 This release

2 files

2.11

2 files

2.10

1 file

2.9

1 file

2.8

1 file

2.7

1 file

2.6

1 file

2.5

1 file

2.4

1 file

2.3

1 file

2.2

1 file

2.1

1 file

2.0.post1

1 file

2.0

1 file

1.5

1 file

1.4

1 file

1.3

1 file

1.2

1 file

1.1

1 file

1.0.post1

2 files

1.0

3 files

0.9

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page