Template Compliance
Compare a research project's LaTeX preamble against the working-paper template bundled with the installed latex skill. Classify every difference, produce a scored report, and optionally apply changes interactively.
When to Use
- After the template has been updated and you want to check older papers
- Before submission — verify the preamble is clean and up to date
- When a paper has mysterious compilation issues (often a stale preamble)
- During periodic maintenance or
system-audit
- When starting work on a paper that hasn't been touched in a while
When NOT to Use
- Setting up a new project — the separate
init-project-research workflow
copies the template; this skill audits an existing project
- Fixing compilation errors — use
latex first, then run this
- Non-LaTeX projects — this skill is LaTeX-specific
Critical Rules
- Never edit without
--apply. Default mode is report-only. Without --apply, the skill produces a report and exits.
- Never auto-apply Conflict items. Conflicts always require explicit user confirmation via
the available structured-question mechanism.
- Semantic comparison, not line-by-line. Compare packages, options, commands, and environments as logical units — not raw text diffs.
- Preserve project-specific additions. Items classified as Keep are informational. Never suggest removing them unless they conflict with a template feature.
- Template is the reference, not the authority. Projects may legitimately diverge. The skill reports differences — the user decides what to act on.
- Compile after applying. If
--apply makes any changes, always verify with latex.
Protocol
Phase 1: Locate & Parse
Resolve the project path. Accept as argument or use CWD. Resolve to absolute path.
Find the project's preamble files. The canonical location is the Overleaf document, accessed via the paper/ symlink in the project directory. Search in this order:
- New format (
.sty files): paper/your-template.sty + paper/your-bib-template.sty (Overleaf symlink — preferred)
- Legacy format:
paper/settings.tex (Overleaf symlink)
- If no
paper/ symlink exists, check the project root for your-template.sty (or settings.tex)
- Project root:
your-template.sty + your-bib-template.sty or settings.tex (for local-only projects without Overleaf)
- Any
\input{settings} or \usepackage{your-template} in main.tex pointing elsewhere
NEVER check settings/style files in subdirectories like docs/, to-sort/, docs/venues/, or any non-paper location. Only the main paper's preamble is relevant.
New papers: copy templates/venues/_shared/user-math.sty in alongside the venue kit and \usepackage{user-math} (clash-safe; [notheorems] if the kit owns theorem envs) rather than hand-declaring \E/\Prob/\R/\argmax. Existing compiling papers are not retrofitted — see templates/venues/_shared/README.md.
If no preamble files are found, report error and exit.
Read the template. Resolve the sibling installed skill path, then use
../latex/templates/working-paper/ relative to this skill. Compare the two
.sty files there, with settings.tex as a legacy fallback when present.
If no template files are found, report "Bundled working-paper template not
found — reinstall or repair the latex skill" and exit.
Parse both files into semantic blocks:
| Block |
What to extract |
| Packages |
Package name + options (e.g., [dvipsnames]{xcolor}) |
| Hyperref |
All \hypersetup{} key-value pairs + \urlstyle |
| Bibliography |
System (biblatex/natbib), all options, \addbibresource, source mappings, field clearing (\AtEveryBibitem), possessive citation commands |
| Custom commands |
All \newcommand, \renewcommand, \DeclareMathOperator, \newcolumntype |
| Theorem environments |
All \newtheorem declarations with their styles and counters |
| Build config |
Canonical .latexmkrc byte identity and optional .latexmkrc.local validity |
For packages, normalise options: \usepackage[a,b]{pkg} and \usepackage[b,a]{pkg} are equivalent.
Phase 2: Compare
For each semantic block, compare the project against the template. Detailed check tables for each block: references/comparison-checklist.md
Blocks to compare: Packages (missing, extra, options, load order, duplicates) · Hyperref (missing keys, different values, urlstyle, cleveref ordering) · Bibliography (system mismatch, options, source mappings, field clearing, possessive citations) · Custom Commands (missing, different definitions, column types, math commands) · Theorem Environments (missing, different styles/counters, numberwithin) · Build Config (canonical .latexmkrc identity and local-supplement policy)
Phase 3: Classify
Label every difference with: Adopt (missing from project, safe to add) · Keep (project-specific, informational) · Conflict (needs human judgement, always ask) · Drop (redundant/superseded).
Full classification rules and when-to-use-each-label guidance: references/comparison-checklist.md
Phase 4: Check Auxiliaries
Check main.tex (preamble loading, documentclass, printbibliography, no stale bibliography commands), compare .latexmkrc byte-for-byte with the resolved canonical, and inspect any .latexmkrc.local for a forbidden $pdf_mode assignment.
Full check tables: references/comparison-checklist.md
Phase 5: Report
Produce a structured compliance report. Full format: references/report-format.md
Quality Score
Apply numeric quality scoring using the shared framework: ../shared/quality-scoring.md
Start at 100 and deduct per issue:
| Tier |
Deduction |
Examples |
| Critical |
-15 to -25 |
Missing or divergent canonical .latexmkrc, natbib vs biblatex conflict, missing hyperref, hyperref/cleveref load order wrong |
| Major |
-5 to -14 |
Missing common packages (booktabs, microtype, enumitem), missing dvipsnames, duplicate package loads, missing custom commands (\todo, \red, \blue), missing source mappings, missing field clearing, missing cleveref |
| Minor |
-1 to -4 |
Missing optional packages, different hyperref colours, missing theorem environments, missing math operators, missing \numberwithin |
Verdicts
| Score |
Verdict |
Meaning |
| 95-100 |
Ship |
Fully aligned with template |
| 90-94 |
Ship with notes |
Minor gaps, acceptable to proceed |
| 80-89 |
Revise |
Meaningful gaps — fix before submission |
| 60-79 |
Revise (major) |
Significant drift — several features missing |
| 0-59 |
Blocked |
Major conflicts or missing infrastructure — consider full resync |
Report Sections
- Header: Project name, path, score, date
- Summary table: Counts by classification (Adopt / Keep / Conflict / Drop)
- Per-item detail: Grouped by semantic block, showing classification + what/why
- Auxiliaries: main.tex and .latexmkrc checks
- Recommendations: Prioritised list of suggested actions
If --apply is not set, end with:
Run `latex-template <path> --apply` to interactively apply changes.
Phase 6: Apply (--apply mode only)
Apply changes in dependency order to avoid compilation breakage:
- Package options (e.g., add
dvipsnames to xcolor)
- Missing packages (insert in correct position relative to existing packages)
- Hyperref configuration (update
\hypersetup{} block)
- Bibliography changes (only if user approves — always
the available structured-question mechanism for system changes)
- Custom commands (append after existing commands section)
- Theorem environments (append after existing theorem section)
.latexmkrc (with approval, copy the resolved canonical verbatim; migrate legitimate project settings to .latexmkrc.local and never set $pdf_mode there)
- Cleanup (remove duplicates, drop redundancies)
Apply Rules
- Show a summary first. Before making any edits, present the full list of changes to be applied (Adopt + Drop items) and ask for confirmation.
- Conflicts are always individual. Each Conflict item gets its own
the available structured-question mechanism with the template version, project version, and context.
- Keep items are never touched. They appear in the report but are skipped during apply.
- Preserve comments and whitespace. When inserting packages, match the project's existing formatting style (e.g., if packages are grouped with comment headers, add to the right group).
- Log what was changed. After applying, list every edit made.
Phase 7: Verify (--apply mode only)
After applying changes:
- Compile with
latex. This handles any secondary issues the changes might introduce.
- Report the result:
- If compilation succeeds: report success + number of changes applied
- If compilation fails: report the error, suggest reverting specific changes, and note which change likely caused the issue
What This Skill Does NOT Do
- Does not rewrite
main.tex structure. Only checks \input{settings} and bibliography commands.
- Does not check content quality. The separate
proofread workflow covers
prose quality when that additional review is wanted.
- Does not manage
.bib files. Use an installed bibliography validator, or perform direct cite-key and metadata checks.
- Does not handle journal-specific formatting. Use
retarget-journal for that.
- Does not compare across projects. Checks one project at a time against the template.
Examples
Report only (default)
"latex-template ~/papers/costly-voice"
Produces a compliance report without making any changes.
Apply mode
"latex-template ~/papers/costly-voice --apply"
Produces the report, then interactively applies Adopt and Drop changes with user confirmation.
Current directory
"Check my template compliance"
Runs on the current working directory in report-only mode.
After template update
"I updated the template — check all my papers"
Run on each project individually. This skill checks one project at a time.
Cross-References
../latex/templates/working-paper/ — the bundled template this skill compares against
latex — used in Phase 7 to verify compilation after applying changes
audit-project-research — complementary: checks directory structure, this checks LaTeX preamble
- Installed bibliography validator — optional complement for citation keys and metadata; this skill checks bibliography system configuration
init-project-research — creates projects from the template; this skill
verifies ongoing compliance
retarget-journal — handles journal-specific formatting (different concern)
1---2name: latex-template3description: Compare a project's LaTeX preamble and conventions against the canonical working-paper template. Use when diagnosing template drift without converting venue formats or editing prose.4---56# Template Compliance78> Compare a research project's LaTeX preamble against the working-paper template bundled with the installed `latex` skill. Classify every difference, produce a scored report, and optionally apply changes interactively.910## When to Use1112- After the template has been updated and you want to check older papers13- Before submission — verify the preamble is clean and up to date14- When a paper has mysterious compilation issues (often a stale preamble)15- During periodic maintenance or `system-audit`16- When starting work on a paper that hasn't been touched in a while1718## When NOT to Use1920- **Setting up a new project** — the separate `init-project-research` workflow21 copies the template; this skill audits an existing project22- **Fixing compilation errors** — use `latex` first, then run this23- **Non-LaTeX projects** — this skill is LaTeX-specific2425---2627## Critical Rules28291. **Never edit without `--apply`.** Default mode is report-only. Without `--apply`, the skill produces a report and exits.302. **Never auto-apply Conflict items.** Conflicts always require explicit user confirmation via `the available structured-question mechanism`.313. **Semantic comparison, not line-by-line.** Compare packages, options, commands, and environments as logical units — not raw text diffs.324. **Preserve project-specific additions.** Items classified as **Keep** are informational. Never suggest removing them unless they conflict with a template feature.335. **Template is the reference, not the authority.** Projects may legitimately diverge. The skill reports differences — the user decides what to act on.346. **Compile after applying.** If `--apply` makes any changes, always verify with `latex`.3536---3738## Protocol3940### Phase 1: Locate & Parse41421. **Resolve the project path.** Accept as argument or use CWD. Resolve to absolute path.432. **Find the project's preamble files.** The canonical location is the **Overleaf document**, accessed via the `paper/` symlink in the project directory. Search in this order:44 - **New format (`.sty` files):** `paper/your-template.sty` + `paper/your-bib-template.sty` (Overleaf symlink — **preferred**)45 - **Legacy format:** `paper/settings.tex` (Overleaf symlink)46 - If no `paper/` symlink exists, check the project root for `your-template.sty` (or `settings.tex`)47 - Project root: `your-template.sty` + `your-bib-template.sty` or `settings.tex` (for local-only projects without Overleaf)48 - Any `\input{settings}` or `\usepackage{your-template}` in `main.tex` pointing elsewhere4950 **NEVER** check settings/style files in subdirectories like `docs/`, `to-sort/`, `docs/venues/`, or any non-paper location. Only the main paper's preamble is relevant.5152 **New papers:** copy `templates/venues/_shared/user-math.sty` in alongside the venue kit and `\usepackage{user-math}` (clash-safe; `[notheorems]` if the kit owns theorem envs) rather than hand-declaring `\E`/`\Prob`/`\R`/`\argmax`. Existing compiling papers are not retrofitted — see `templates/venues/_shared/README.md`.5354 If no preamble files are found, report error and exit.55563. **Read the template.** Resolve the sibling installed skill path, then use57 `../latex/templates/working-paper/` relative to this skill. Compare the two58 `.sty` files there, with `settings.tex` as a legacy fallback when present.5960 If no template files are found, report "Bundled working-paper template not61 found — reinstall or repair the `latex` skill" and exit.62634. **Parse both files into semantic blocks:**6465 | Block | What to extract |66 |-------|----------------|67 | **Packages** | Package name + options (e.g., `[dvipsnames]{xcolor}`) |68 | **Hyperref** | All `\hypersetup{}` key-value pairs + `\urlstyle` |69 | **Bibliography** | System (biblatex/natbib), all options, `\addbibresource`, source mappings, field clearing (`\AtEveryBibitem`), possessive citation commands |70 | **Custom commands** | All `\newcommand`, `\renewcommand`, `\DeclareMathOperator`, `\newcolumntype` |71 | **Theorem environments** | All `\newtheorem` declarations with their styles and counters |72 | **Build config** | Canonical `.latexmkrc` byte identity and optional `.latexmkrc.local` validity |7374 For packages, normalise options: `\usepackage[a,b]{pkg}` and `\usepackage[b,a]{pkg}` are equivalent.7576---7778### Phase 2: Compare7980For each semantic block, compare the project against the template. Detailed check tables for each block: [`references/comparison-checklist.md`](references/comparison-checklist.md)8182Blocks to compare: **Packages** (missing, extra, options, load order, duplicates) · **Hyperref** (missing keys, different values, urlstyle, cleveref ordering) · **Bibliography** (system mismatch, options, source mappings, field clearing, possessive citations) · **Custom Commands** (missing, different definitions, column types, math commands) · **Theorem Environments** (missing, different styles/counters, numberwithin) · **Build Config** (canonical `.latexmkrc` identity and local-supplement policy)8384---8586### Phase 3: Classify8788Label every difference with: **Adopt** (missing from project, safe to add) · **Keep** (project-specific, informational) · **Conflict** (needs human judgement, always ask) · **Drop** (redundant/superseded).8990Full classification rules and when-to-use-each-label guidance: [`references/comparison-checklist.md`](references/comparison-checklist.md#phase-3-classification-rules)9192---9394### Phase 4: Check Auxiliaries9596Check `main.tex` (preamble loading, documentclass, printbibliography, no stale bibliography commands), compare `.latexmkrc` byte-for-byte with the resolved canonical, and inspect any `.latexmkrc.local` for a forbidden `$pdf_mode` assignment.9798Full check tables: [`references/comparison-checklist.md`](references/comparison-checklist.md#phase-4-auxiliary-checks)99100---101102### Phase 5: Report103104Produce a structured compliance report. Full format: [`references/report-format.md`](references/report-format.md)105106#### Quality Score107108Apply numeric quality scoring using the shared framework: [`../shared/quality-scoring.md`](../shared/quality-scoring.md)109110Start at **100** and deduct per issue:111112| Tier | Deduction | Examples |113|------|-----------|----------|114| **Critical** | -15 to -25 | Missing or divergent canonical `.latexmkrc`, natbib vs biblatex conflict, missing `hyperref`, `hyperref`/`cleveref` load order wrong |115| **Major** | -5 to -14 | Missing common packages (booktabs, microtype, enumitem), missing `dvipsnames`, duplicate package loads, missing custom commands (\todo, \red, \blue), missing source mappings, missing field clearing, missing `cleveref` |116| **Minor** | -1 to -4 | Missing optional packages, different hyperref colours, missing theorem environments, missing math operators, missing `\numberwithin` |117118#### Verdicts119120| Score | Verdict | Meaning |121|-------|---------|---------|122| 95-100 | Ship | Fully aligned with template |123| 90-94 | Ship with notes | Minor gaps, acceptable to proceed |124| 80-89 | Revise | Meaningful gaps — fix before submission |125| 60-79 | Revise (major) | Significant drift — several features missing |126| 0-59 | Blocked | Major conflicts or missing infrastructure — consider full resync |127128#### Report Sections1291301. **Header**: Project name, path, score, date1312. **Summary table**: Counts by classification (Adopt / Keep / Conflict / Drop)1323. **Per-item detail**: Grouped by semantic block, showing classification + what/why1334. **Auxiliaries**: main.tex and .latexmkrc checks1345. **Recommendations**: Prioritised list of suggested actions135136If `--apply` is not set, end with:137```138Run `latex-template <path> --apply` to interactively apply changes.139```140141---142143### Phase 6: Apply (--apply mode only)144145Apply changes in dependency order to avoid compilation breakage:1461471. **Package options** (e.g., add `dvipsnames` to xcolor)1482. **Missing packages** (insert in correct position relative to existing packages)1493. **Hyperref configuration** (update `\hypersetup{}` block)1504. **Bibliography changes** (only if user approves — always `the available structured-question mechanism` for system changes)1515. **Custom commands** (append after existing commands section)1526. **Theorem environments** (append after existing theorem section)1537. **`.latexmkrc`** (with approval, copy the resolved canonical verbatim; migrate legitimate project settings to `.latexmkrc.local` and never set `$pdf_mode` there)1548. **Cleanup** (remove duplicates, drop redundancies)155156#### Apply Rules157158- **Show a summary first.** Before making any edits, present the full list of changes to be applied (Adopt + Drop items) and ask for confirmation.159- **Conflicts are always individual.** Each Conflict item gets its own `the available structured-question mechanism` with the template version, project version, and context.160- **Keep items are never touched.** They appear in the report but are skipped during apply.161- **Preserve comments and whitespace.** When inserting packages, match the project's existing formatting style (e.g., if packages are grouped with comment headers, add to the right group).162- **Log what was changed.** After applying, list every edit made.163164---165166### Phase 7: Verify (--apply mode only)167168After applying changes:1691701. **Compile with `latex`.** This handles any secondary issues the changes might introduce.1712. **Report the result:**172 - If compilation succeeds: report success + number of changes applied173 - If compilation fails: report the error, suggest reverting specific changes, and note which change likely caused the issue174175---176177## What This Skill Does NOT Do178179- **Does not rewrite `main.tex` structure.** Only checks `\input{settings}` and bibliography commands.180- **Does not check content quality.** The separate `proofread` workflow covers181 prose quality when that additional review is wanted.182- **Does not manage `.bib` files.** Use an installed bibliography validator, or perform direct cite-key and metadata checks.183- **Does not handle journal-specific formatting.** Use `retarget-journal` for that.184- **Does not compare across projects.** Checks one project at a time against the template.185186---187188## Examples189190### Report only (default)191192> "latex-template ~/papers/costly-voice"193194Produces a compliance report without making any changes.195196### Apply mode197198> "latex-template ~/papers/costly-voice --apply"199200Produces the report, then interactively applies Adopt and Drop changes with user confirmation.201202### Current directory203204> "Check my template compliance"205206Runs on the current working directory in report-only mode.207208### After template update209210> "I updated the template — check all my papers"211212Run on each project individually. This skill checks one project at a time.213214---215216## Cross-References217218- **`../latex/templates/working-paper/`** — the bundled template this skill compares against219- **`latex`** — used in Phase 7 to verify compilation after applying changes220- **`audit-project-research`** — complementary: checks directory structure, this checks LaTeX preamble221- **Installed bibliography validator** — optional complement for citation keys and metadata; this skill checks bibliography system configuration222- **`init-project-research`** — creates projects from the template; this skill223 verifies ongoing compliance224- **`retarget-journal`** — handles journal-specific formatting (different concern)