latex
Skill150 starsChanged 10 days agoMITView on GitHub
Compile one specified LaTeX document, resolve build errors, audit citations, and report build quality. Use when a .tex source must be built or a concrete compilation failure repaired. Not for corpus-wide build checks, visual polish after a clean build, or creating a project; use $latex-health-check, $latex-polish, or $latex-scaffold.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- letsloose501/sqs-agent-memorytheir own version, first seen Nov 3, 2026
- indigoHatter/claude-latex-skilltheir own version, first seen Oct 20, 2026
- oakreader/oakreadertheir own version, first seen Oct 16, 2026
- labdaps/labskillstheir own version, first seen Oct 13, 2026
- andrewzeitlin/claude_skillstheir own version, first seen Oct 8, 2026
- hameefy/claude-latex-skilltheir own version, first seen Oct 8, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- oakreader/oakreader★ 46same name
- hameefy/claude-latex-skill★ 12same name
- vekzz-dev/opencode-skills★ 4same name
- labdaps/labskills★ 2same name
- letsloose501/sqs-agent-memory★ 2same name
- andrewzeitlin/claude_skills★ 0same name
- indigoHatter/claude-latex-skill★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository89 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- beamer-deckSkill
- bib-coverageSkill
- bib-filterSkill
- bib-parseSkill
- brief-compliance-checkSkill
- camera-readySkill
- causal-designSkill
- checkpointSkill
- code-archaeologySkill
- compile-knowledgeSkill
- computational-experimentsSkill
- cross-language-checkSkill
- data-analysisSkill
- devils-advocateSkill
- docs-consistencySkill
- docxSkill
- experiment-designSkill
- grill-meSkill
- handoffSkill
- ideasSkill
- init-project-courseSkill
- init-project-lightSkill
- init-project-orchestrationSkill
- init-projectSkill
- insights-deckSkill
- interview-meSkill
- knowledge-lintSkill
- latex-diffSkill
- latex-health-checkSkill
- latex-polishSkill
- latex-postersSkill
- latex-scaffoldSkill
- latex-templateSkill
- lean-checkSkill
- math-proofSkill
- mcp-builderSkill
- method-auditSkill
- multi-perspectiveSkill
- numerical-checkSkill
- pdfSkill
- pipeline-manifestSkill
- playwright-cliSkill
- postmortemSkill
- pre-commit-auditSkill
- pre-submission-reportSkill
- project-deckSkill
- project-safetySkill
- proof-readabilitySkill
- proofreadSkill
- python-envSkill
- quarto-deckSkill
- reorgSkill
- replication-auditSkill
- replication-packageSkill
- retarget-journalSkill
- review-clusterSkill
- review-responseSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
28 rules. 0 are common, 15 are distinctive, and 13 are very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
15
Distinctive
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
When compilation fails and you want automatic diagnosis and repair
- Distinctive: line 18
When you want a post-compilation citation audit
- Distinctive: line 36
Start at 100, deduct per issue found, apply verdict.
- Distinctive: line 41
NEVER write BibTeX entries from memory: Verify against authoritative metadata sources such as Crossref or the DOI resolver before writing.
- Distinctive: line 43
Maximum 5 fix iterations: If the document still has errors after 5 auto-fix cycles, stop and report the unresolved errors to the user.
- Distinctive: line 44
Never silently swallow errors: Every fix must be reported: what was wrong, what was changed, and which file was edited.
- Very specific: line 46
Citation audit requires clean compilation: Only run the \cite{} vs .bib cross-check after zero errors.
- Very specific: line 58
Create
out/directory: if it doesn't exist: mkdir -p <project-dir>/out. - Distinctive: line 63
Run up to 5 iterations. Each iteration:
- Very specific: line 75
Read out/<filename>.log in full.
- Distinctive: line 79
Check the log against the known error patterns below.
- Very specific: line 87
Check the log against these patterns.
- Distinctive: line 100
If an error matches, read the full fix from the reference and apply it.
- Very specific: line 106
If the .tex file is inside a paper-{venue}/paper/ structure (where paper/ is a symlink to Overleaf):
- Distinctive: line 119
If either condition is false, skip this sub-step silently.
- Distinctive: line 125
After the loop ends (either clean compilation or max iterations reached), report:
- Very specific: line 208
chktex: if installed: chktex -q -n8 -n44 main.tex 2>&1 | grep -v "^$". - Very specific: line 210
latexindent -k: if installed: latexindent -k main.tex 2>&1. - Very specific: line 225
If no findings: "No source pathologies detected." If chktex or latexindent ran, note their PASS/N-warnings status.
- Distinctive: line 261
After all phases complete, compute the quality score:
- Very specific: line 263
Read references/quality-rubric.md for deduction mappings.
- Very specific: line 286
When the compile produced a PDF (and any backup copy), emit an outputs manifest and run the shared verifier per _shared/verify-outputs.md:
- Very specific: line 288
Write manifest to <project>/.claude/state/outputs-manifest-<UTC-timestamp>.json listing every file written this invocation (PDF, backup PDF …
- Distinctive: line 297
If the verifier exits non-zero, do not commit.
- Very specific: line 307
All LaTeX build artifacts (.aux, .log, .bbl, .fls, etc.) go to an out/ subfolder relative to the source file.
- Distinctive: line 320
When a project is synced to Overleaf (via Dropbox or Git):
- Very specific: line 322
Always use .latexmkrc to enforce out/ — Overleaf ignores this file too
- Distinctive: line 328
Not all projects sync to Overleaf.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
LaTeX Document Compilation
Default compilation skill for all LaTeX documents. Compiles with autonomous error detection and resolution (up to 5 iterations), runs a citation audit on clean builds, and produces a quality score.
When to Use
- Default method for all LaTeX compilation
- Any
.texfile that should compile to PDF - When compilation fails and you want automatic diagnosis and repair
- When you want a post-compilation citation audit
When NOT to Use
- Markdown documents — use plain markdown, not LaTeX
- Quick notes or drafts — LaTeX overhead not worth it
- Documents that don't need citations, equations, or precise formatting
- Documents with exotic custom classes that need manual debugging
Quality Scoring
Apply numeric quality scoring using the shared framework and skill-specific rubric:
- Framework:
../shared/quality-scoring.md— severity tiers, thresholds, verdict rules - Rubric:
references/quality-rubric.md— issue-to-deduction mappings for this skill
Start at 100, deduct per issue found, apply verdict. Include the Score Block in the final report.
Critical Rules
- Build artifacts go to
out/, PDF stays in the source directory. Use this skill's fail-closed canonical bundle attemplates/build-config/.latexmkrc; do not hand-write anEND { system(...) }copy block because it can mask latexmk's failure status and copy stale PDFs. For VS Code builds, use the bundled canonical recipe that explicitly loads%DIR%/.latexmkrc—-cdalone is insufficient. - NEVER write BibTeX entries from memory. Verify against authoritative metadata sources such as Crossref or the DOI resolver before writing. Use an installed literature-search workflow when one is configured.
- Check document class before adding packages. Some classes load packages internally (e.g.,
elsarticleloadsnatbib— adding\usepackage{natbib}causes errors). - Maximum 5 fix iterations. If the document still has errors after 5 auto-fix cycles, stop and report the unresolved errors to the user.
- Never silently swallow errors. Every fix must be reported: what was wrong, what was changed, and which file was edited.
- Preserve user intent. Auto-fixes should be minimal and conservative. Add packages or overrides — never remove user content.
- Citation audit requires clean compilation. Only run the
\cite{}vs.bibcross-check after zero errors. - Validate new bibliography entries. The built-in citation audit checks key cross-references. When
.bibentries were added or modified, also check DOI resolution, required fields, author formatting, and whether a preprint has a published version. If a dedicated bibliography validator is installed, use it for this extended check; otherwise perform and report the direct checks.
Protocol
Phase 1: Pre-flight
- Locate the
.texfile. Resolve the path (absolute or relative to CWD). - Identify the project directory — the folder containing the
.texfile. - Ensure the canonical
.latexmkrcexists in the project directory. Resolvetemplates/build-config/.latexmkrcrelative to this installed skill and stop if the bundle is missing. Never recreate a partial version from memory. Compare an existing file byte-for-byte with the bundled canonical; do not overwrite divergence blindly. Move project-specific bibliography paths or custom dependencies into.latexmkrc.local; move engine selection into a% !TEX program = ...driver comment. Replacing a divergent file remains an explicit migration. - Create
out/directory if it doesn't exist:mkdir -p <project-dir>/out. - Identify the
.bibfile(s) referenced in the document (scan for\bibliography{},\addbibresource{}, or\bibinput{}). Note their paths for Phase 5.
Phase 2: Compile-Fix Loop
Run up to 5 iterations. Each iteration:
Step 2a — Compile
cd <project-dir> && latexmk -interaction=nonstopmode <filename>.tex 2>&1Capture the full output. The log file will be at out/<filename>.log.
Step 2b — Read the log
Read out/<filename>.log in full. Parse for errors and warnings.
Step 2c — Classify errors
Check the log against the known error patterns below. If an error matches, apply the fix and go to Step 2a. If no known pattern matches, record the error as unresolved and stop the loop.
Same-error circuit breaker. Independent of the 5-iteration cap: if the same error (same line family, same pattern signature) survives 3 consecutive fix attempts, stop the loop early. Continued attempts on a stuck error compound damage rather than resolve it. Report what was tried, quote the log line, and ask the user how to proceed. A common signature: Illegal parameter number jumping between line numbers as you edit — that is the diagnostic for a parameterized TikZ style defined inside a Beamer frame; see skills/shared/tikz-rules.md Rule 11.
Known Error Patterns & Auto-Fixes
Check the log against these patterns. Full fix instructions: references/known-errors.md
| # | Pattern | Key log signature |
| 1 | Missing package | File '<pkg>.sty' not found or undefined command from known package |
| 2 | Font/symbol conflicts | Command \<name> already defined |
| 3 | Undefined citation | Citation '<key>' ... undefined or biblatex entry not found |
| 4 | Missing image/file | File '<path>' not found (pdftex.def or LaTeX) |
| 5 | Stale auxiliary files | Corrupted .aux/.bbl/.bcf, or no \bibstyle command |
| 6 | Beamer/enumitem clash | Option clash for package enumitem or \item already defined |
| 7 | xcolor option conflicts | Option clash for package xcolor or undefined \rowcolor |
| 8 | TikZ reserved keys | I do not know the key '/tikz/<name>' or pgfkeys error |
If an error matches, read the full fix from the reference and apply it. If no pattern matches, record as unresolved and stop the loop.
2.4 PDF backup (paper directories only)
Only run if the compile-fix loop above ended with a successful compilation (PDF exists).
If the .tex file is inside a paper-{venue}/paper/ structure (where paper/ is a symlink to Overleaf):
- Identify the paper wrapper — the parent of the
paper/symlink (e.g.,paper-jbdm/). - Create the backup directory:
mkdir -p <paper-wrapper>/backup - Copy the PDF:
cp <paper-wrapper>/paper/<filename>.pdf <paper-wrapper>/backup/<wrapper-name>_vcurrent.pdf
Detection logic:
- The project directory containing the
.texfile is a symlink namedpaper. - Its parent directory name starts with
paper-. - If either condition is false, skip this sub-step silently.
Phase 3: Final Report
After the loop ends (either clean compilation or max iterations reached), report:
Compilation Status
| Field | Value |
| Status | Clean / Errors remaining |
| Iterations | N of 5 |
| Pages | (from log: Output written on ... (N pages)) |
| LaTeX/package warnings | Count of Warning-tagged log lines (undefined refs, font subs, package warnings) |
| Typographic boxes | Overfull/underfull h/vboxes by severity — see box report below (NOT counted by a Warning grep) |
| Fixes applied | List each fix: what error, what was changed, which file |
| Unresolved errors | List any errors that couldn't be auto-fixed |
How to extract page count
grep -o "Output written on .* ([0-9]* page" out/<filename>.log | grep -o "[0-9]* page"How to count warnings and boxes
Warnings and typographic boxes are separate — box messages are not
Warning-tagged, so a single Warning grep misses every overfull/underfull box.
Report both, using the recipes in ../shared/overfull-boxes.md:
# LaTeX/package warnings (refs, fonts, packages)
grep -c "Warning" out/<filename>.log
# Overfull/underfull boxes (the thing the Warning grep cannot see)
grep -cE 'Overfull \\[hv]box \([0-9.]+pt too (wide|high)\)' out/<filename>.log
grep -cE 'Underfull \\[hv]box \(badness [0-9]+\)' out/<filename>.logBox report (typographic quality)
Extract the top offenders by overflow magnitude and report each box ≥ 1 pt with
its location, width, and a remediation tier per the severity gradient + ladder in
../shared/overfull-boxes.md:
awk -F'[()]' '/Overfull \\[hv]box/ {
split($2, a, "pt"); w = a[1] + 0;
loc = $0; sub(/.*too (wide|high)\) */, "", loc);
printf "%7.1f pt %s\n", w, loc
}' out/<filename>.log | sort -rn | head -20Report only — do not silently reword prose to close a box (rules/manuscript-edit-budget.md).
The only safe auto-fix is inserting \usepackage{microtype} when genuinely absent.
Breadcrumb: Append to .planning/state.md (if exists) or .context/current-focus.md:
### [latex] Compilation complete [YYYY-MM-DD HH:MM]
- **Done:** [Clean/Errors remaining, N iterations, N pages, N fixes applied]
- **Outputs:** [PDF at <path>]
- **Next:** [Citation audit (if clean) or manual error resolution]Phase 4: Visual-Fragility Source Lint (clean builds only)
Only run if Phase 2 ended with zero errors. Sits between the final report (Phase 3) and the citation audit (Phase 5). Catches LaTeX source patterns that compile clean but produce visually fragile output — the failure class the title-page incident (2026-06-19) exposed.
Full detector catalogue with regex signatures, severity tiers, remediation, and false-positive caveats: references/source-pathologies.md.
What to run
Nine grep-based source-pathology detectors against
main.texplus any\input/\include'd files:# Pattern Tier 1 Spacing hacks fighting global spacing ( \onehalfspacing+ local\\[-Xcm]/\vspace{-…})Major 2 Manual vertical-rhythm surgery (repeated \vspace/\vskip/\pagebreakin body)Moderate–Major 3 Line breaks as layout engine ( \\/\newline/\linebreakinside\section/\caption)Moderate–Major 4 Forced-float carpet bombing ( [H]/[!h]pinning,\FloatBarrieroveruse)Moderate 5 Shrink-to-fit tables/figures ( \resizebox{\textwidth}{!}{…},\adjustbox{width=\textwidth})Major 6 Tiny-table typography hacks ( \scriptsize/\tinyin tables; negative\tabcolsep;\arraystretch<0.9)Moderate–Major 7 Absolute / overlap positioning ( \raisebox,\makebox[0pt],\llap,\rlap,\smash,\hspace*) outside mathMajor 8 Fixed-width layout assumptions ( p{Xcm},\begin{minipage}{Xcm},\parbox{Xcm})Moderate 9 Label-before-caption inside floats ( \label{…}precedes\caption{…}in afigure/tableblock)Major chktexif installed:chktex -q -n8 -n44 main.tex 2>&1 | grep -v "^$". Advisory only — collect warnings; deduct -1 each, capped at -10. Skip ifchktexnot on PATH.latexindent -kif installed:latexindent -k main.tex 2>&1; echo "Exit: $?". Source-cleanliness smoke test. Non-zero exit → -3 once. Skip iflatexindentnot on PATH.
Output
Append a Source pathologies subsection to the Phase 3 report:
### Source pathologies
| Pattern | Location | Detail | Tier |
|---------|----------|--------|------|
| 1 Spacing-hacks | titlepage, line 56 | `\\[-0.3cm]` under global `\onehalfspacing` (line 43) | Major |
| 9 Label-before-caption | tab:results, line 412 | `\label` at L410 precedes `\caption` at L413 | Major |If no findings: "No source pathologies detected." If chktex or latexindent ran, note their PASS/N-warnings status.
Auto-fix scope
Phase 4 is report-only, with one exception: Pattern 1 ("Spacing hacks fighting global spacing") has a deterministic remediation (wrap the affected block in \begin{singlespace}…\end{singlespace}, delete the negative kerns). The skill offers this as an opt-in fix in the final report; the user accepts or declines per case. Do not auto-apply.
For Patterns 2–9 and tool findings: report only.
When to skip
- Compile failed in Phase 2 (pathology lint is meaningless without a build).
- User explicitly invoked
latex --no-lint.
Phase 5: Citation Audit (clean builds only)
Only run this phase if Phase 2 ended with zero errors.
- Extract all
\citekeys from the.texfile (and any\input/\includefiles):- Match
\cite{...},\citep{...},\citet{...},\textcite{...},\parencite{...},\autocite{...}, and multi-key variants like\cite{key1,key2}.
- Match
- Extract all bib entry keys from the
.bibfile(s): match@<type>{<key>,. - Cross-reference:
| Check | What it finds |
| Missing in .bib | Keys cited in .tex but absent from .bib |
| Unused in .tex | Keys defined in .bib but never cited |
| Possible typos | Near-matches between missing cite keys and existing bib keys |
- Report the results as a table. Do not modify any files during the audit — report only.
Phase 6: Quality Score
After all phases complete, compute the quality score:
- Read
references/quality-rubric.mdfor deduction mappings. - Log every issue from Phases 2-5 (unresolved errors, remaining warnings, overfull/underfull boxes from the Phase 3 box report, citation mismatches). The rubric deducts per box by severity (
>10pt: -5,1-10pt: -2, underfull:-1) — feed it the box report, not aWarningcount. - Compute score (100 - total deductions), apply verdict per
../shared/quality-scoring.md. - Append the Score Block to the compilation report:
## Quality Score
| Metric | Value |
|--------|-------|
| **Score** | XX / 100 |
| **Verdict** | Ship / Ship with notes / Revise / Revise (major) / Blocked |
### Deductions
| # | Issue | Tier | Deduction | Category |
|---|-------|------|-----------|----------|
| 1 | [description] | [tier] | -X | [category] |
| | **Total deductions** | | **-XX** | |6.1 Output verification (before commit)
When the compile produced a PDF (and any backup copy), emit an outputs manifest and run the shared verifier per _shared/verify-outputs.md:
- Write manifest to
<project>/.claude/state/outputs-manifest-<UTC-timestamp>.jsonlisting every file written this invocation (PDF, backup PDF if 2.4 ran, log files). Run:
uv run python "<skills-root>/_shared/verify_outputs.py" \ --manifest "$MANIFEST" \ --project-root "$PROJECT_ROOT"- If the verifier exits non-zero, do not commit. Surface the missing-files list and stop.
Closes the "hallucinated outputs" failure class (commit b2cff75, 2026-04-18).
Configuration Reference
Output Directory
All LaTeX build artifacts (.aux, .log, .bbl, .fls, etc.) go to an out/ subfolder relative to the source file. The PDF is copied back to the source directory after each successful build, so it lives alongside the .tex file for easy access.
The PDF-copy convention is enforced in two places — keep them in sync when making changes:
.latexmkrc(per-project) — the canonical success-gated copy-back logic handles terminal builds- VS Code
.vscode/settings.json(per-workspace) — explicitly loads the document-directory canonical before-cd
VS Code integration, engine auto-detection (pdfLaTeX/XeLaTeX/LuaLaTeX), manual override configs, reference checking scripts, and manual compilation commands:
references/latex-configs.md
Overleaf-Synced Projects
When a project is synced to Overleaf (via Dropbox or Git):
- The
out/directory will sync to Overleaf but Overleaf ignores it — this is fine - Always use
.latexmkrcto enforceout/— Overleaf ignores this file too - Overleaf compiles independently on its server; local compilation is for verification only
- The
.bstfile (e.g.,elsarticle-harv.bst) lives in the source directory, notout/
Local-Only Projects (No Overleaf)
Not all projects sync to Overleaf. For local-only projects:
- The same
out/and.latexmkrcconventions apply — this keeps the working directory clean regardless of sync method - There is no
paper/symlink —.texfiles live directly in the project root or a subdirectory
Templates
See references/templates.md for working paper template location, files, citation style toggle, bibliography file naming conventions, and bibliography command reference.
Related Skills
| Situation | Delegate to |
| Need to find or verify a bibliography entry | Installed scholarly-search workflow, or direct authoritative metadata lookup |
| Full academic proofreading after clean compilation | proofread |
Detailed .bib validation beyond cite-key matching | Installed bibliography validator, when available |
| Beamer presentations specifically | beamer-deck (which uses this skill internally for compilation) |
| Fleet-wide compilation health check | latex-health-check (project discovery, 3 iterations per project, cross-project checks) |
Examples
Basic usage
"Compile my paper at
~/papers/mcdm-survey/main.tex"
Runs the full protocol: pre-flight → compile-fix loop → report → citation audit → quality score.
After fixing a known issue
"Recompile — I added the missing package manually"
Runs from Phase 2 directly (pre-flight can be skipped if .latexmkrc and out/ already exist).
Targeted fix
"My paper won't compile — something about Bbbk"
Identifies as Pattern 2 (font conflict), applies the \let\Bbbk\relax fix, recompiles.
Source format. Paper prose stays one line per paragraph; normalize edited files with .scripts/latex_paragraph_format.py --apply and recompile. Canonical: rules/latex-source-format.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

