Skip to main content

Validates arXiv compatibility and cleans a LaTeX .zip project in one command

Project description

latex2arxiv

PyPI Downloads Tests Python License: MIT

The arXiv submission pipeline โ€” CLI, CI, and AI. Project in, arXiv-ready zip out.

latex2arxiv paper.zip --compile          # zip
latex2arxiv paper/ --compile             # directory
latex2arxiv https://github.com/u/p.git   # git URL

Try the built-in demo:

pip install latex2arxiv
latex2arxiv --demo --compile

This processes a bundled self-documenting paper and opens the cleaned PDF. The cleaned demo's PDF is attached to every GitHub Release as demo_project_arxiv.pdf.

Before / After

On a real statistics paper: 934 โ†’ 40 files, 80.6 MB โ†’ 3.1 MB.

latex2arxiv demo
Before (Overleaf export) After (latex2arxiv output)
๐Ÿ“ Images/ ๐Ÿ“ Images/
๐Ÿ“„ JASA_main.tex ๐Ÿ“„ JASA_main.tex
๐Ÿ“„ JASA_main_backup.tex ๐Ÿ“„ ref.bib
๐Ÿ“„ main_bak_svm.tex ๐Ÿ“„ Supplementary_Materials.tex
๐Ÿ“„ cover_letter.md
๐Ÿ“„ response.tex
๐Ÿ“„ ref.bib
๐Ÿ“„ JASA_main.aux/.log/.bbl/.pdf
๐Ÿ“ jasa_comments/, jasa_revision/
... (and ~930 more)
934 files, 80.6 MB 40 files, 3.1 MB

Works everywhere

Terminal โ€” one command, any input format:

latex2arxiv paper.zip --compile

CI โ€” gate your paper repo on arXiv compliance:

- run: pip install latex2arxiv && latex2arxiv paper.zip --dry-run

AI agents โ€” Claude, Cursor, or Copilot validate and fix issues in conversation:

pip install "latex2arxiv[mcp]"
{"mcpServers": {"latex2arxiv": {"command": "latex2arxiv-mcp"}}}

Who is this for?

  • You wrote your paper in Overleaf and need a clean, arXiv-ready zip without manually pruning files. โ†’ Overleaf โ†’ arXiv quickstart
  • You want to gate a paper repo's CI on arXiv compliance so a bad merge can't slip through. โ†’ --dry-run + non-zero exit on [error] (details)
  • Your paper uses custom revision-tracking macros (\added, \deleted, \textcolor{red}{...}) that you need stripped before submission. โ†’ Custom removal rules

What it does

Feature What it does
๐Ÿ“ฆ One command, any input Accepts a .zip, directory, or git URL; outputs an arXiv-ready .zip; optionally compiles and opens the PDF for review
โœ‚๏ธ Prunes your project to submission-ready Keeps only files reachable from your main .tex; removes build artifacts, editor files, cover letters, unused figures
๐Ÿงน Cleans your .tex Strips comments, removes \todo{} / \hl{} / draft packages, handles nested braces correctly (\deleted{see \cite{x}} works)
๐Ÿšจ Catches submission blockers before you upload [error] for shell-escape packages that will fail on arXiv (minted, pythontex); [warn] for biblatex without .bbl, missing index files, oversized output, problematic filenames โ€” full list

Also: BibTeX normalization, \pdfoutput=1 injection, image resizing (Pillow), --dry-run preview, --demo for first-run.

Dependency tracking respects \input, \include, \subfile, \includegraphics, \graphicspath, and \bibliography. Commented-out commands are ignored.

latex2arxiv vs. arxiv_latex_cleaner

arxiv_latex_cleaner is the incumbent โ€” Google-backed, mature, and cleans well. The key difference: it won't tell you that \usepackage{minted} will fail on arXiv, won't produce the .zip you upload, and has no exit code for CI gating.

latex2arxiv arxiv_latex_cleaner
Output format Any input โ†’ .zip Cleaned directory
Pre-flight [error] / [warn] (details) โœ… โŒ
Non-zero exit on errors โœ… โŒ
--compile preview โœ… โŒ
Auto-detect main .tex โœ… โŒ
Brace-balanced config โœ… โŒ
BibTeX normalization โœ… โœ…
--dry-run โœ… โŒ
Built-in --demo โœ… โŒ
Image resizing (Pillow) โœ… โœ…
MCP server (AI agent integration) โœ… โŒ
GitHub Action + pre-commit hook โœ… โŒ
PDF compression (Ghostscript) โŒ โœ…
PNG โ†’ JPG conversion โŒ โœ…
Maturity 7 regression fixtures, live pdflatex+biber end-to-end CI ~5kโ˜…, years

Installation

pip install latex2arxiv

On macOS, if you get an externally-managed-environment error, use pipx:

brew install pipx
pipx install latex2arxiv

Or from source:

git clone https://github.com/YuZh98/latex2arxiv
cd latex2arxiv
pip install .

pdflatex is required only for --compile (install via TeX Live or MacTeX).

Once installed, try the built-in demo to see the tool in action:

latex2arxiv --demo --compile

Usage

latex2arxiv input [output.zip] [--main MAIN_TEX] [--resize PX] [--config FILE] [--compile]

input can be a .zip file, a directory of LaTeX sources, or a git URL (https or ssh). Directories are zipped internally; git URLs are cloned with --depth 1.

Flag Description
--main FILENAME Specify the main .tex file (e.g. JASA_main.tex). Auto-detected via \documentclass if omitted.
--resize PX Resize images so longest side โ‰ค PX pixels (e.g. --resize 1600). Requires Pillow.
--config FILE YAML config file for custom removal rules (see below).
--compile Run pdflatex on the output and open the resulting PDF.
--dry-run Preview what would be removed/processed without writing any output.
--demo Run the built-in demo project (no input file needed).

Examples

latex2arxiv paper.zip                                  # zip input
latex2arxiv paper/                                     # directory input
latex2arxiv https://github.com/user/paper.git          # git URL input
latex2arxiv paper.zip out.zip --main main.tex --compile
latex2arxiv paper.zip --resize 1600 --compile          # shrink images
latex2arxiv paper.zip --config arxiv_config.yaml       # custom rules
latex2arxiv paper.zip --dry-run                        # preview without writing
latex2arxiv --demo --compile                           # run the built-in demo

Pre-flight checks

Before producing the output zip, latex2arxiv validates the project against arXiv's LaTeX submission guide. [error] lines block submission (the tool exits non-zero, useful for CI gating); [warn] lines are advisory and do not affect the exit code.

$ latex2arxiv paper.zip --dry-run
  [error] \usepackage{minted} requires shell-escape โ€” arXiv compiles without it; this submission will fail to build
  [error] \usepackage{psfig} โ€” arXiv no longer supports the psfig package
  [warn]  \today used in \date โ€” arXiv may rebuild the PDF and the date will change
  [warn]  .eps image found: photo.eps โ€” pdflatex does not support .eps; convert to .pdf or .png
  [warn]  \printindex used but no .ind file at root โ€” build locally and re-run latex2arxiv

Summary: 2 errors, 7 warnings

Either [error] line would have caused arXiv to reject the submission after upload. The exit code is non-zero on errors, so a CI step like latex2arxiv paper.zip --dry-run fails the build before the bad submission ever leaves the repo.

See docs/pre-flight.md for the full list of checks and silent fixes.

Custom removal rules (--config)

For revision markup and other project-specific cleanup, create a YAML config file. A template is in arxiv_config.yaml.

# Remove command AND its argument (text is lost)
commands_to_delete:
  - \deleted
  - \revision

# Remove command but KEEP its argument text
commands_to_unwrap:
  - \color{red}       # \color{red}text โ†’ text
  - \textcolor{red}   # \textcolor{red}{text} โ†’ text
  - \added            # \added{new text} โ†’ new text

# Remove entire environments
environments_to_delete:
  - response

# Raw regex (last resort โ€” prefer the verbs above when they fit).
replacements:
  - pattern: '\\textcolor\{[^}]*\}\{([^}]*)\}'
    replacement: '\1'

The brace-balanced matcher correctly handles nested commands like \deleted{see \cite{x}}. Unknown top-level keys warn โ€” typos like command_to_delete (singular) no longer silently no-op.

Integrations

Surface Status Details
CLI โœ… pip install latex2arxiv
GitHub Action โœ… action.yml
pre-commit hook โœ… latex2arxiv-dryrun
MCP server (AI agents) โœ… pip install "latex2arxiv[mcp]" โ€” setup
VS Code extension ๐Ÿ”œ Planned
Homebrew formula ๐Ÿ”œ Planned

Known limitations

Dynamically constructed filenames โ€” \includegraphics{\figpath/fig1} cannot be resolved statically and the image will be deleted. Expand path macros before running.

\subfile vs \input path resolution โ€” \input/\include paths resolve relative to the project root; \subfile paths resolve relative to the subfile's own directory. Unusual nested setups may cause images to be incorrectly pruned; use --compile to verify.

--compile is a local sanity check โ€” a successful local compile doesn't guarantee arXiv will compile it. arXiv pins specific TeX Live versions. Always check the arXiv submission preview after uploading.

Project details


Download files

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

Source Distribution

latex2arxiv-0.8.0.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

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

latex2arxiv-0.8.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file latex2arxiv-0.8.0.tar.gz.

File metadata

  • Download URL: latex2arxiv-0.8.0.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for latex2arxiv-0.8.0.tar.gz
Algorithm Hash digest
SHA256 91089414e3c92ea10dd366ebc5b17317c565b72a1dc536c289a994175c21f568
MD5 e70e90019b1024b716ef4ae01bbf5a60
BLAKE2b-256 b5c45e338db4620ba91acc77270510f43de7ef69d2adbc35a505731d63b4d481

See more details on using hashes here.

Provenance

The following attestation bundles were made for latex2arxiv-0.8.0.tar.gz:

Publisher: publish.yml on YuZh98/latex2arxiv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file latex2arxiv-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: latex2arxiv-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for latex2arxiv-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9792d1233f4f61e2518fc68f76647d9085df854e0e7196d0d2996f42851a17c8
MD5 b25af930ce0c2f333912b70490acda06
BLAKE2b-256 a01a26d03a26078b651b7d500565fdda107ea9e65c84ce1281f56822bb9e7db5

See more details on using hashes here.

Provenance

The following attestation bundles were made for latex2arxiv-0.8.0-py3-none-any.whl:

Publisher: publish.yml on YuZh98/latex2arxiv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page