Use when you need to compile a LaTeX document — includes autonomous error resolution, citation audit, and quality scoring.
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.
.tex file that should compile to PDFApply numeric quality scoring using the shared framework and skill-specific rubric:
../shared/quality-scoring.md — severity tiers, thresholds, verdict rulesreferences/quality-rubric.md — issue-to-deduction mappings for this skillStart at 100, deduct per issue found, apply verdict. Include the Score Block in the final report.
out/, PDF stays in the source directory. Ensure .latexmkrc exists with $out_dir = 'out' and an END {} block to copy the PDF back (see pre-flight below). For VS Code builds, .latexmkrc in subdirectories is not picked up — see "VS Code Integration" section for the required .vscode/settings.json config./literature skill.elsarticle loads natbib — adding \usepackage{natbib} causes errors).\cite{} vs .bib cross-check after zero errors./bib-validate when new citations were added. The citation audit only checks key cross-references. When .bib entries were added or modified since the last validation, also run /bib-validate for full metadata quality checks (preprint staleness, DOI presence, required fields, author formatting). This is mandatory..tex file. Resolve the path (absolute or relative to CWD)..tex file..latexmkrc exists in the project directory with at minimum:
$out_dir = 'out';
# Copy PDF back to source directory after build
END { system("cp $out_dir/*.pdf . 2>/dev/null") if defined $out_dir; }
If a .latexmkrc already exists, verify it sets $out_dir = 'out' and has the END {} block. If either is missing, add it. Do not overwrite other settings.out/ directory if it doesn't exist: mkdir -p <project-dir>/out..bib file(s) referenced in the document (scan for \bibliography{}, \addbibresource{}, or \bibinput{}). Note their paths for Phase 4.Run up to 5 iterations. Each iteration:
cd <project-dir> && latexmk -interaction=nonstopmode <filename>.tex 2>&1
Capture the full output. The log file will be at out/<filename>.log.
Read out/<filename>.log in full. Parse for errors and warnings.
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.
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.
Only run if Phase 2 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):
paper/ symlink (e.g., paper-jbdm/).mkdir -p <paper-wrapper>/backupcp <paper-wrapper>/paper/<filename>.pdf <paper-wrapper>/backup/<wrapper-name>_vcurrent.pdf
Detection logic:
.tex file is a symlink named paperpaper-After the loop ends (either clean compilation or max iterations reached), report:
| Field | Value |
|---|---|
| Status | Clean / Errors remaining |
| Iterations | N of 5 |
| Pages | (from log: Output written on ... (N pages)) |
| Warnings | Count of remaining warnings (overfull/underfull hbox, etc.) |
| Fixes applied | List each fix: what error, what was changed, which file |
| Unresolved errors | List any errors that couldn't be auto-fixed |
grep -o "Output written on .* ([0-9]* page" out/<filename>.log | grep -o "[0-9]* page"
grep -c "Warning" out/<filename>.log
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]
Only run this phase if Phase 2 ended with zero errors.
\cite keys from the .tex file (and any \input/\include files):
\cite{...}, \citep{...}, \citet{...}, \textcite{...}, \parencite{...}, \autocite{...}, and multi-key variants like \cite{key1,key2}..bib file(s): match @<type>{<key>,.| 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 |
After all phases complete, compute the quality score:
references/quality-rubric.md for deduction mappings.../shared/quality-scoring.md.## 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** | |
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) — Perl END {} block copies PDF after terminal/Claude Code builds.vscode/settings.json (per-workspace) — explicit latexmk args in LaTeX Workshop tool definitionVS Code integration, engine auto-detection (pdfLaTeX/XeLaTeX/LuaLaTeX), manual override configs, reference checking scripts, and manual compilation commands:
When a project is synced to Overleaf (via Dropbox or Git):
out/ directory will sync to Overleaf but Overleaf ignores it — this is fine.latexmkrc to enforce out/ — Overleaf ignores this file too.bst file (e.g., elsarticle-harv.bst) lives in the source directory, not out/Not all projects sync to Overleaf. For local-only projects:
out/ and .latexmkrc conventions apply — this keeps the working directory clean regardless of sync methodpaper/ symlink — .tex files live directly in the project root or a subdirectoryWhen creating a new working paper, use the template. The canonical location is the local git repo:
templates/latex-wp/ (in Task Management — canonical source, git-tracked)The template contains:
| File | Purpose |
|---|---|
main.tex | Document entry point with structure |
your-template.sty | Packages, layout, formatting, math environments |
your-bib-template.sty | Bibliography config (biblatex, source cleanup, Harvard style) |
references.bib | Bibliography file (initially empty) |
out/ | Compilation output directory |
To create a new working paper:
main.tex with your title, author, abstractreferences.biblatexmk main.texThe template uses biblatex/biber with a toggle for Harvard vs generic authoryear style.
In main.tex, control the style via package option:
\usepackage[harvard]{your-bib-template} % Harvard style (default)
\usepackage[noharvard]{your-bib-template} % Generic authoryear style
Always name the bibliography file references.bib — for any paper, whether using the working paper template or not. This is the standard naming convention across all projects.
The template uses biblatex. In main.tex:
\printbibliography % (not \bibliography{references})
If you need natbib instead, do not load your-bib-template and use:
\bibliographystyle{agsm}
\bibliography{references}
| Situation | Delegate to |
|---|---|
| Need to find or verify a bibliography entry | /literature |
| Full academic proofreading after clean compilation | /proofread |
Detailed .bib validation beyond cite-key matching | /bib-validate |
| 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) |
"Compile my paper at
~/papers/mcdm-survey/main.tex"
Runs the full protocol: pre-flight → compile-fix loop → report → citation audit → quality score.
"Recompile — I added the missing package manually"
Runs from Phase 2 directly (pre-flight can be skipped if .latexmkrc and out/ already exist).
"My paper won't compile — something about Bbbk"
Identifies as Pattern 2 (font conflict), applies the \let\Bbbk\relax fix, recompiles.