Diagnostics & Error Handling

latex_it parses raw compiler logs from xelatex, lualatex, and pdflatex to present clean, categorized diagnostic messages. Instead of wading through hundreds of lines of TeX console output, errors and warnings are categorized into clear tiers with actionable remediation hints.

Error Diagnostics Comparison: latexmk vs latex_it
See the Diagnostic Showcase Gallery for more side-by-side comparisons on real errors.


1. The 4-Tier Diagnostic Hierarchy

Diagnostics are organized into four severity levels:

┌────────────────────────────────────────────────────────┐
│  Errors     Compilation failures (syntax, missing file)│
│  Alerts     Structural flaws & large overfull hboxes   │
│  Warnings   Standard typesetting & citation warnings   │
│  Whatevers  Harmless noise (suppressed by default)     │
└────────────────────────────────────────────────────────┘
Tier Description Examples Default Behavior
Errors Hard compilation failures that prevent PDF generation. Syntax errors, undefined commands, runaway arguments, missing packages. Highlighted in red; suppresses lower tiers so the root failure is immediately visible.
Alerts Serious structural issues or major layout defects. Multiply-defined labels, overfull \hbox $\ge 24\text{pt}$, inverted labels before captions. Highlighted in yellow/bold; always displayed.
Warnings Actionable layout and reference issues. Overfull \hbox ($2.5\text{pt} < \text{pt} < 24\text{pt}$), underfull \vbox, undefined references, missing citations. Displayed in normal output. Deduplicated per line.
Whatevers Minor cosmetic noise with negligible visual impact. Micro overfull \hbox ($\le 2.5\text{pt}$), hyperref bookmark token removals, font substitution notices. Suppressed from output; total count reported in the summary line (Whatevers: N (suppressed)).

Why “Alerts” and “Whatevers”?

Standard LaTeX has an all-or-nothing philosophy: either a run halts on a fatal syntax error, or it succeeds with exit code 0. Everything else is dumped into a single undifferentiated stream of Warning lines.

latex_it introduced Alerts and Whatevers to solve the two opposite failure modes of this model: Silent Corruptions (False Negatives) and Warning Fatigue (False Positives).

What Are “Alerts” (and Why Do They Matter)?

Alerts represent silent fatal flaws — bugs where LaTeX happily exits with code 0 and produces a PDF, but the document’s content, references, or layouts are fundamentally corrupted.

Standard tools like latexmk treat these as clean builds because the compiler did not crash. Authors routinely submit papers with these bugs without realizing it.

Key Examples of Alerts:

How latex_it Handles Alerts:

What Are “Whatevers” (and Why Are They Not Important)?

Whatevers represent harmless compiler chatter — low-level internal TeX notices that have zero or sub-pixel impact on the rendered document, but create immense “warning fatigue” that drowns out real problems.

Key Examples of Whatevers:

Why They Are Not Important:

How latex_it Handles Whatevers:

  1. Suppressed by default: Kept out of your terminal so you can focus 100% on genuine text and layout issues.
  2. Counted in the summary line: Always visible at the end of compilation (Whatevers: 3 (suppressed)).
  3. Inspectable anytime (l -a): Running l -a (or --all) instantly unhides all Whatevers in cyan.
  4. Configurable threshold: Set your own tolerance with --whatever-pt <pt> (e.g. 1.0) or in .l.jsonc.

2. Explanation Mode (-x / --explain)

Pass -x or --explain to print a boxed, plain-English explanation on the first occurrence of each diagnostic type:

l -x paper.tex

Example explanation box:

┌─── [Why: Overfull \hbox] ──────────────────────────────────────────┐
│ Text on this line extends beyond the printable margin boundary.    │
│ Fix: Rephrase the line, add hyphenation hints (\-), or wrap in     │
│ \sloppy / \begin{sloppypar} if necessary.                          │
└────────────────────────────────────────────────────────────────────┘

Explanations appear at most once per error type to keep terminal output compact.


3. Threshold Configuration

You can customize the threshold boundaries between Whatevers, Warnings, and Alerts via CLI flags or .l.jsonc:

# Set overfull hbox alert threshold to 30pt
l --alert-hbox 30.0

# Set micro-overflow whatever threshold to 1.0pt
l --whatever-pt 1.0

In .l.jsonc:

{
  "alert_overfull_pt": 30.0,
  "whatever_pt": 1.0
}

To see all diagnostics without any filtering, use -a / --all:

l -a paper.tex

4. Proactive Semantic Checks

latex_it includes proactive checks that catch subtle bugs before or during compilation:

Inverted \label Before \caption

In LaTeX floats (figure, table), placing \label{...} before \caption{...} causes the label to bind to the outer section counter instead of the figure number. latex_it flags inverted labels with an Alert.

Type 3 (Bitmap) Font Detection

Journals and indexing services (ACM TAPS, IEEE PDF eXpress, arXiv) often reject PDFs containing Type 3 raster fonts. When pdffonts is available, latex_it checks the compiled PDF and reports the specific pages where Type 3 fonts appear.

Pre-Flight Brace Auditing

The built-in brace checker (LaTeXBraceChecker) runs before LaTeX starts, catching unmatched {, }, and mismatched brackets like {] across environments without waiting for a full compiler run.

Bibliography Source Pinpointing

When LaTeX crashes during \printbibliography or \bibliography due to a syntax error in a .bib file (such as an unescaped _ or &), standard TeX engines only report \printbibliography in main.tex. latex_it hooks BibLaTeX’s entry processing, intercepts the active citation key, locates the entry and line in your .bib databases, and emits a companion error with line number and token hints. See Troubleshooting Bibliography Errors for details.


5. GNU Standard Compiler Mode (-cc / --compile) & Editor Integration

For standard compiler integration with editors, IDEs, and build runners (e.g. Emacs M-x compile, Vim :make, VS Code tasks, CI log matchers), latex_it provides the -cc / --compile flag.

Format Specification (GNU §4.4)

Diagnostics are emitted directly to $stderr in standard GNU format:

sourcefile:lineno:column: severity: message
# Standard compilation run (shorthand -cc or --compile)
l -cc paper.tex

# With color explicitly enabled
l -cc --color paper.tex

# Include low-severity whatevers as 'note:' diagnostics
l -cc -a paper.tex

For AUCTeX or editors parsing raw TeX parenthesized file-tracking blocks:

# Emit AUCTeX-compatible error output
l --emacs paper.tex

[!NOTE] --compile and --emacs represent different integration formats and are mutually exclusive.


6. AI Agent & LLM Mode (-llm / --agent) and Structured JSON (--json)

Autonomous AI coding agents (Claude Code, Antigravity, OpenCode, Cursor, Aider) interact with build systems through terminal execution. Standard TeX output wastes tokens, floods context windows with secondary warnings, and breaks regex log parsers with ANSI escapes.

latex_it provides the dedicated -llm (or --agent) profile tailored for agent interaction:

# Run in token-optimized agent mode
l -llm paper.tex

Key Behaviors of --llm Mode

  1. Plaintext Guarantee: Zero ANSI color escape sequences (\e[...]) and zero OSC 8 terminal hyperlinks (\e]8;;...). Plaintext parses cleanly and avoids wasting 15–25 tokens per diagnostic line.
  2. Silence on Clean Success: If compilation succeeds with no actionable diagnostics or if targets are already up-to-date, latex_it exits 0 with completely empty stdout and stderr, consuming zero agent context tokens.
  3. Warning Category Folding: When a document has dozens of identical warnings (such as 50 missing citations from an empty bibliography), --llm displays the first 2 occurrences with exact file:line:col and folds the remaining occurrences into a single summary note:
    paper.tex:12: warning: [alert] undefined citation 'knuth1984'
    paper.tex:15: warning: [alert] undefined citation 'lamport1994'
    latex_it: note: 48 more undefined citations in paper.tex (pass -a to show all)
    
  4. Suppression of Underfull Boxes: Low-level micro-notes (whatevers) are suppressed by default unless -a is explicitly passed.
  5. Actionable Unparsed Crash Reporting: When a TeX engine crashes with an unclassified syntax or memory failure, --llm mode extracts the last 8 lines of the compiler log into a GNU-compliant error block:
    paper.tex:1: error: compilation failed with unclassified error
    paper.tex:1: note: compiler log tail:
    > ! Emergency stop.
    > <read 2> \relax
    > l.42 \include{missing}
    

Structured JSON Mode (--json)

For automated pipelines, programmatic IDE integrations, or external tool bridges, --json outputs a single structured JSON object to stdout:

l --json paper.tex

Example JSON response:

{
  "success": true,
  "exit_code": 0,
  "pdf_path": "paper.pdf",
  "summary": {
    "errors": 0,
    "alerts": 0,
    "warnings": 1,
    "whatevers": 0
  },
  "diagnostics": [
    {
      "file": "paper.tex",
      "line": 42,
      "col": 1,
      "tier": "warnings",
      "category": "undefined_citation",
      "message": "undefined citation 'knuth1984'",
      "token": "knuth1984"
    }
  ]
}

FAQ: Why a CLI Flag Instead of an MCP Server?


7. Error Reference Catalog

For an in-depth catalog of 55 common LaTeX compilation errors, their root causes, and minimal reproducer examples: