LaTeX LLM Cleaner
A CLI tool that turns a LaTeX project or a PowerPoint deck into one clean text file for a language model to read.
- LaTeX: inlines every
\input/\include, strips comments, expands idiosyncratic macros, and inlines the bibliography, so the model sees one self-contained document instead of a directory of fragments and private shorthand. - PowerPoint: extracts each slide's text, tables and notes, with equations converted from Office MathML to LaTeX. Readers built only on
python-pptxsilently drop every text box that contains an equation, because those boxes sit insidemc:AlternateContent; this tool reads them.
What happened to PDF and Word input (1.0)
Versions before 1.0 also converted PDFs (with optional Surya OCR) and DOCX files, and could describe figures with the Gemini API. Each of those now has a better answer:
| Input | Use instead |
|---|---|
| Short PDF (≲ 20 pages) | Give it to the model directly. Current models read rendered page images, math included. |
| Long PDF | Marker on a GPU: marker_single paper.pdf --force_ocr --paginate_output. On a 15-paper test battery it beat this tool's OCR on equations, two-column reading order, tables and figure captions. |
.docx |
pandoc -t markdown file.docx (equations come out as LaTeX). |
| Figure descriptions | Not needed: models can look at the figure (the file, or the rendered page) themselves. |
Installation
uv tool install latex-llm-cleaner # or: pipx install latex-llm-cleaner
Upgrading from 0.x: uv tool install --force latex-llm-cleaner (the old [ocr] extra no longer exists).
Usage
latex-llm-cleaner paper.tex # cleaned LaTeX to stdout
latex-llm-cleaner paper.tex -o cleaned.tex # to a file
latex-llm-cleaner paper.tex --no-bibliography # skip bibliography inlining
latex-llm-cleaner slides.pptx -o slides.md # slides as markdown
latex-llm-cleaner slides.pptx --notes -o slides.md # include speaker notes
All steps are on by default; disable them individually:
latex-llm-cleaner INPUT_FILE [options]
-o, --output FILE Write to FILE (default: stdout)
--no-flatten Disable \input/\include flattening
--no-comments Disable comment removal
--no-macros Disable macro expansion
--keep-usepackage Keep \usepackage lines (dropped by default)
--no-bibliography Disable bibliography inlining
--notes Include speaker notes (PPTX)
--encoding ENC File encoding (default: utf-8)
-v, --verbose Print processing info to stderr
LaTeX pipeline
Four steps, in order:
- Flatten includes: inline
\input{},\include{}and\subfile{}recursively, resolved from the main file's directory, with cycle detection. - Remove comments: strip
%comments, respecting\%escapes and verbatim environments. - Expand macros: substitute
\newcommand,\renewcommand,\defand\DeclareMathOperatorwhere the expansion reads better than the name (\Secref{x}→Section~\ref{x},\train→\mathcal{D}); leave self-documenting names like\normalone and just drop their definitions. Pure-rendering preamble (\usetikzlibrary,\definecolor,\newtheorem, …) and\usepackagelines are removed (--keep-usepackagekeeps the latter). Handles 0–9 arguments, optional arguments with defaults, and nested macros. - Inline bibliography: use the
.bblif present, otherwise parse the.bib, and replace\bibliography{}with athebibliographyblock.
Figures are left as \includegraphics{path}: the path tells the reader which file to open.
PowerPoint output
Each slide becomes # Slide N: Title, separated by ---. Tables become pipe tables, equations become $...$ LaTeX, and pictures become [Image] (with the picture's alt text when it has some). Speaker notes are excluded unless --notes is given.
Development
uv run pytest
Metadata
Release files for latex-llm-cleaner 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| latex_llm_cleaner-1.0.0.tar.gz | 60.0 kB | Without provenance | Details for latex_llm_cleaner-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latex_llm_cleaner-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for latex_llm_cleaner-1.0.0-py3-none-any.whl |
Total release size: 84.8 kB
Release files / latex_llm_cleaner-1.0.0.tar.gz
| Download URL | latex_llm_cleaner-1.0.0.tar.gz |
|---|---|
| Size | 60.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25fcd42a7ed1aa34a08120a098e40679ead25b5f97154bd54c32b49a14ac0c44
|
|
BLAKE2b-256 checksum How to use checksums |
157ab9c2fb0665fe4327a98c2cf1a513a2a7177e03ea88256b86117cc8138dd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / latex_llm_cleaner-1.0.0-py3-none-any.whl
| Download URL | latex_llm_cleaner-1.0.0-py3-none-any.whl |
|---|---|
| Size | 24.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afb3706be73edde6f38459fcc50fd4c541777f7cc1ab1e7397e9864885728db9
|
|
BLAKE2b-256 checksum How to use checksums |
2c29e6e6557a61c4abcf35d79e0505eda8a647a795ad09d1803015f87ebb88c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for latex-llm-cleaner 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.