skillfed

latexcodec

A lexer and codec to work with LaTeX code in Python.

latexcodec v3.0.1 1.9M downloads/30d#3,487 on PyPI30
Permissive license MIT AGING released

What it is and what it does

latexcodec is a Python codec that translates between LaTeX markup and Unicode text. It works by registering a codec that lets you encode Unicode strings into LaTeX commands and decode LaTeX commands back into Unicode characters. The package is designed for short text fragments—like individual BibTeX fields or paragraphs—rather than full LaTeX documents, because it does not run a full LaTeX compiler and its handling of non-character-selecting commands (macros, formatting directives) is best-effort and may require manual adjustment.

The encoder converts Unicode characters outside the ASCII range into LaTeX equivalents (e.g., `ü` becomes `\"u`, `¥` becomes `\yen`), and the decoder reverses this process. The codec also normalizes whitespace and removes comments during decoding. LaTeX commands that the codec does not recognize are passed through unchanged, which can result in hybrid strings containing both literal Unicode and unexpanded LaTeX control sequences.

Use it for:

  • Normalize and convert author names or titles in BibTeX entries between LaTeX and Unicode representations.
  • Decode LaTeX-encoded metadata fields in academic document processing pipelines.
  • Encode Unicode text with accented characters into LaTeX for inclusion in .tex files.
  • Clean and canonicalize LaTeX fragments in text mining or citation parsing workflows.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python codec to convert between LaTeX-encoded text and Unicode, suitable for processing short text fragments like BibTeX entries or paragraphs rather than full documents.

Yes, if you need to convert between LaTeX and Unicode for short text fragments in academic or bibliography workflows. The package is stable, has no dependencies, and carries a permissive license. The aging maintenance status (423 days since last release) is not a blocker for stable use, but be aware that new LaTeX commands will not be added without community contribution.

Install

latexcodec on PyPI

pip

pip install latexcodec

uv

uv add latexcodec

poetry

poetry add latexcodec

Installing latexcodec

Before you install

Low install friction with no runtime dependencies. Maintenance is aging—last release was 423 days ago—but the package remains in production/stable status and the repository is not archived.

License in practice

MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

import codecs
codecs.register(lambda name: __import__('latexcodec').LatexCodec())
latex_text = b'\\"u'
decoded = latex_text.decode('latex')
print(decoded)

Verify before relying

  • Whether the package's stated recommendation to use an alternative reflects a known limitation or deprecation plan.
  • Completeness of LaTeX command coverage and whether unrecognized commands degrade gracefully in real-world use.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance aging — 423 days since the last release
Last repo commit
First released
Downloads 1,857,172/month — #3,487 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: latexcodec-3.0.1-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Text Processing :: FiltersTopic :: Text Processing :: Markup :: LaTeX

Tags

latex to unicode conversionbibtex text encodinglatex codec pythonunicode latex decoderlatex character encoding
bibtexlatex-conversion

More Filters packages