FormaTeX

\begin{article}

draft — not published

AI Review of LaTeX Documents — Catch Errors Before Submission

Audit your LaTeX document for deprecated commands, missing packages, mismatched environments, and style problems — with a prioritized fix list.

AI Review of LaTeX Documents — Catch Errors Before Submission

You spent three weeks writing a paper. You submit it to the journal. Two days later you get a rejection email — not from peer review, but from the editorial system. Your PDF failed to compile. The culprit: a deprecated \bf command that TeX Live 2023 no longer accepts, buried in a macro you copied from a 2009 Stack Overflow answer. This is the exact problem the latex-review Claude Code skill exists to solve.

The Problem with Manual LaTeX Review

LaTeX documents accumulate technical debt faster than most people realize. You pull in snippets from old papers, copy equation environments from colleagues, and mix packages that were written in different decades. None of this is obvious until compilation fails — and compilation failures in LaTeX are notoriously opaque. A single unescaped & in a text paragraph produces a cascade of errors that looks nothing like the actual cause.

For developers building PDF generation pipelines on top of an API like FormatEx, this is a production reliability problem. If users are uploading LaTeX documents and your system is compiling them server-side, every deprecated command, every missing package declaration, every mismatched environment is a failed job, a 500 response, and a frustrated user. You need a way to audit documents before they hit the compiler.

The latex-review skill brings AI-powered static analysis to your LaTeX workflow directly inside Claude Code. It catches the class of errors that only show up at compile time — before you submit, before you deploy, before your users notice.

How to Install

The skill lives in the FormatEx latex-skills repository. You have four install options depending on how much of the skill set you want.

Install just the review skill:

bash
cp -r skills/latex-review ~/.claude/skills/

Install the full LaTeX meta-skill bundle (includes review, fix, write, math, structure, citations, and explain):

bash
cp -r skills/latex ~/.claude/skills/

Install the FormatEx meta-skill (LaTeX skills plus FormatEx API integration skills):

bash
cp -r skills/formatex ~/.claude/skills/

Install everything:

bash
cp -r skills/latex-full ~/.claude/skills/

Once installed, the skill is available in any Claude Code session. You invoke it with /latex-review followed by a file path or by pasting document content directly into the prompt.

What latex-review Does

The skill performs a multi-pass audit of your LaTeX document and returns a prioritized issue list. Here is what it checks:

Compilation failures (Priority 1). These are errors that will cause pdflatex, xelatex, or lualatex to exit non-zero. Mismatched \begin/\end pairs, undefined control sequences, missing required arguments, and malformed environments all fall into this category. The skill identifies the exact line and proposes the fix.

Deprecated commands (Priority 2). LaTeX has accumulated a long list of commands that technically still work but are officially deprecated and will eventually be removed. The most common offenders are $$...$$ (use \[...\] instead), eqnarray (use align from amsmath), \bf (use \textbf or \bfseries), \it (use \textit), and \rm (use \textrm). Many journal submission systems run strict TeX Live versions and reject documents that use these. The skill flags every instance with the modern replacement.

Missing package declarations. If your document uses \mathbb, \therefore, or \includegraphics without declaring amsfonts, amssymb, or graphicx in the preamble, the skill catches it. It also detects package conflicts — for example, loading both hyperref and cleveref without the correct load order.

Unescaped special characters. The ten LaTeX special characters (#, $, %, &, _, {, }, ~, ^, \) cause silent or noisy failures when they appear unescaped in text mode. A URL with an & in a footnote, a percentage sign in a caption, an underscore in an author affiliation — these are all real failure modes. The skill scans text-mode content and flags unescaped occurrences.

Style issues (Priority 3). These do not cause compilation failures but indicate quality problems: overfull \hbox warnings, manual spacing with \\ inside paragraphs, hardcoded font sizes instead of semantic commands, \center environment instead of \centering, and similar anti-patterns.

The output is a numbered list sorted by priority, with the line number, the problematic content, the reason it is an issue, and the exact replacement. You can hand this list directly to the latex-fix-errors skill to apply the fixes automatically.

Before and After: What the Workflow Actually Looks Like

Before the skill existed, the review process for a 40-page academic paper looked like this:

  1. Run pdflatex locally, read through 200 lines of log output, identify which warnings are real.
  2. Search the document manually for \bf, $$, and eqnarray using a text editor find function.
  3. Try to remember which packages you need for which commands.
  4. Submit, wait for the journal system to reject the PDF, read the system's error message (usually unhelpful), repeat.
  5. For a generation pipeline: deploy, watch jobs fail in production, read log output, trace back to document content.

This process takes 30-60 minutes for a non-trivial document and requires deep LaTeX knowledge to interpret correctly.

After installing the skill, the workflow is:

text
/latex-review path/to/paper.tex

Claude Code reads the document, runs the full audit, and returns something like:

text
PRIORITY 1 — Compilation failures
[1] Line 47: \begin{equation*} has no matching \end{equation*}. 
    Found \end{align*} instead. Replace with \end{equation*} or 
    change opening to \begin{align*}.

PRIORITY 2 — Deprecated commands (12 instances)
[2] Lines 23, 89, 134, 201, 267, 312, 344, 389, 401, 445, 478, 502:
    $$ ... $$ display math. Deprecated. Replace with \[ ... \].
[3] Lines 56, 78, 203: \bf used for bold text. Replace with \textbf{}.
[4] Line 112: eqnarray environment. Replace with align (requires amsmath).

PRIORITY 2 — Missing packages
[5] Line 112: align environment requires \usepackage{amsmath} in preamble.
    Not found in document.

PRIORITY 2 — Unescaped special characters
[6] Line 334: "costs 50% less" — % will be treated as comment start. 
    Use 50\% instead.

PRIORITY 3 — Style issues
[3] Lines 67, 234: Manual line break \\ inside paragraph. 
    Use \par or blank line for paragraph breaks.

Total time: under 10 seconds. No LaTeX knowledge required to interpret the output. You can then run /latex-fix-errors to apply all fixes automatically, or review them manually if you prefer.

If you are building a PDF generation pipeline using the FormatEx API and you want to validate documents before sending them to the compiler, this skill gives you a client-side audit layer that catches the majority of failures before they consume a compilation job. See the getting started guide for how FormatEx compilation jobs work, and the Go client post for how to integrate document validation into a Go-based pipeline.

Common Use Cases

Academic paper submission. You are submitting to IEEE, ACM, or a Springer journal. These systems run their own TeX Live build and often reject documents with deprecated commands. Run latex-review before uploading to the editorial system. The skill specifically targets the deprecated command patterns that cause the most journal submission failures.

Legacy document modernization. You have a PhD thesis or technical report written in 2010 that you need to recompile for a new purpose. Documents that old almost certainly contain \bf, \it, eqnarray, and $$ throughout. The skill produces a complete inventory of every instance so you know the scope of the modernization work before you start.

CI/CD pipeline validation. If you are running automated LaTeX compilation as part of a documentation pipeline — generating PDFs from source on every commit — latex-review can run as a pre-compile lint step. Fail the build on Priority 1 issues, warn on Priority 2, log Priority 3. This catches regressions before they reach the compilation stage. For teams using FormatEx as the compilation backend, this reduces API usage by not sending documents that will fail.

User-uploaded content moderation. If you are building a product where users upload LaTeX files and your backend compiles them via the FormatEx API, you can run latex-review logic as a validation step before accepting the upload. Return the issue list to the user with a prompt to fix Priority 1 issues before submitting. This improves completion rates and reduces support load. The PHP/Laravel integration guide and the Ruby on Rails guide both show patterns for pre-submission validation in web application contexts.

Teaching and code review. If you are reviewing LaTeX documents written by students or junior colleagues, latex-review gives you an objective baseline audit to share. Instead of manually annotating every \bf in a 60-page document, you hand the person a prioritized list and a clear explanation of why each pattern is problematic.

Serverless PDF generation. In a serverless architecture where each function invocation compiles a document, failed compilations are expensive — you pay for the invocation even when the job fails. Running a review pass before invoking the compiler reduces wasted invocations. The AWS Lambda serverless guide covers this architecture in detail.

The latex-review skill is designed to work in sequence with the rest of the FormatEx Claude Code skill set:

  • latex-fix-errors — Takes the output of latex-review and applies fixes automatically. The natural next step after a review pass.
  • latex-write-markup — Writes LaTeX markup from a description or structure prompt. Useful when you need to add new content that follows current best practices rather than copying old patterns.
  • latex-math-equations — Writes and formats mathematical expressions correctly. Relevant if your review turns up issues in the math environments specifically.
  • latex-document-structure — Audits and improves the high-level structure of a document: section hierarchy, cross-references, float placement. Complements the technical audit that latex-review provides.
  • latex-citations-bibliography — Reviews and fixes bibliography and citation issues, including bibtex vs biblatex inconsistencies.
  • latex-explain-commands — Explains what specific LaTeX commands do. Useful when latex-review flags something you do not recognize.

Start Using It

The latex-review skill is part of the open-source FormatEx latex-skills repository. Install it in two commands, use it from any Claude Code session, and stop discovering compilation errors at the worst possible moment.

bash
cp -r skills/latex-review ~/.claude/skills/

If you are building a product that generates PDFs from LaTeX, FormatEx provides the compilation API — hosted TeX Live, multiple engines, clean REST interface, no infrastructure to maintain. The latex-skills repository gives you the Claude Code layer on top for document authoring, validation, and repair.

Source: github.com/formatex/latex-skills

\end{article}

Back to blog

\related{posts}

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy