--- id: latexcodec version: "3.0.1" license: MIT license_treatment: permissive maintenance: aging --- # latexcodec — A lexer and codec to work with LaTeX code in Python. License: permissive · Maintenance: aging · Downloads: 1.9M/mo ## 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 above — 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 pip install latexcodec uv add latexcodec 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_current - Install friction: low - Maintenance: aging - Downloads: 1.9M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags latex to unicode conversion, bibtex text encoding, latex codec python, unicode latex decoder, latex character encoding, bibtex, latex-conversion [View on SkillFed](https://skillfed.io/packages/latexcodec) · [View on PyPI](https://pypi.org/project/latexcodec/)