Skip to content

Lambenthan/empiricalwiki / i18n/en/skills/paper-compile

paper-compile

Verified

LaTeX compile → PDF — latexmk compile + auto-fix + page count/anonymity/font/[UNCONFIRMED] checks + submission checklist

/paper-compile

Compile a LaTeX paper to PDF, auto-fix common errors, and verify submission requirements. Input: the paper/ directory generated by /paper-draft. Run latexmk compilation, parse errors and attempt auto-fix (missing packages, undefined references, figure paths). Verify page limit, anonymous compliance, font embedding, and clearance of [UNCONFIRMED] markers. Generate a submission checklist.

Inputs

  • paper_dir (optional, default paper/): LaTeX project directory containing main.tex
  • --fix (optional): enable auto-fix mode (automatically install missing packages, correct paths)
  • --checklist (optional): generate a detailed submission checklist (check only, no compilation)

Outputs

  • paper/main.pdf — compiled PDF
  • COMPILE_REPORT (printed to terminal) — compilation status, check results, submission checklist
  • If --fix: modified .tex files (auto-fixed)

Wiki Interaction

Reads

  • wiki/outputs/paper-plan-*.md — retrieve venue information (page limit, anonymity requirements)
  • .claude/skills/shared-references/citation-verification.md — [UNCONFIRMED] marker check rules

Writes

  • paper/main.pdf — compilation output
  • wiki/log.md — appended compilation log

Graph edges created

  • None

Workflow

Precondition: confirm paper/main.tex exists. Confirm latexmk is installed (which latexmk).

Step 1: Compile

  1. First compilation:

    cd paper/ && latexmk -pdf -interaction=nonstopmode main.tex 2>&1
    
  2. Parse compilation output:

    • Collect all errors (! ...)
    • Collect all warnings (Warning: / Overfull / Underfull)
    • Classify:
      • Missing package: ! LaTeX Error: File 'xxx.sty' not found
      • Undefined reference: LaTeX Warning: Reference 'xxx' on page N undefined
      • Undefined citation: LaTeX Warning: Citation 'xxx' on page N undefined
      • Missing figure: ! LaTeX Error: File 'figures/xxx' not found
      • Syntax error: other errors beginning with !
      • Overfull/Underfull: typesetting warnings (non-blocking)
  3. If compilation succeeds (main.pdf generated): proceed to Step 3

  4. If compilation fails: proceed to Step 2

Step 2: Auto-Fix

If --fix is enabled, attempt to auto-fix each error type:

2a. Missing package:

# check if the package is installable via TeX Live
tlmgr info {package-name} 2>/dev/null
# if installable and user confirms:
tlmgr install {package-name}

If not installable: comment out the \usepackage{xxx} line and annotate % TODO: install package {xxx}

2b. Undefined reference/citation:

  • Undefined reference: check if the corresponding \label{} exists; if not, add a placeholder label
  • Undefined citation: check if references.bib contains the key
    • If not: attempt to match from wiki papers and add an [UNCONFIRMED] entry
    • If present but bibtex has not run: re-run latexmk (latexmk usually handles this automatically)

2c. Missing figure:

  • Check if paper/figures/ contains a file with a different extension (.pdf vs .png vs .eps)
  • If found: correct the \includegraphics path
  • If not found: replace with placeholder \missingfigure{xxx} (requires todonotes package)

2d. Syntax error:

  • Common fixes: unclosed {}, mismatched \begin{}/\end{}, illegal characters
  • Attempt to locate the error line number; provide specific fix suggestions
  • If auto-fix is not possible: report error location and suggestions

Re-compile after fixes (up to 3 fix-compile cycles):

cd paper/ && latexmk -pdf -interaction=nonstopmode main.tex 2>&1

Step 3: Verification Checks

After successful compilation, run the following checks:

3a. Page count check:

# get PDF page count
python3 -c "
import subprocess
result = subprocess.run(['pdfinfo', 'paper/main.pdf'], capture_output=True, text=True)
for line in result.stdout.splitlines():
    if line.startswith('Pages:'):
        print(line.split(':')[1].strip())
"

Compare against the venue page limit (retrieved from the PAPER_PLAN venue or the venue table in academic-writing.md).

  • Exceeds limit: report number of pages over limit; suggest compressing or moving content to appendix
  • Under limit: report remaining space; suggest adding content

3b. Anonymity check: Scan all .tex files:

  • Search for author names (if \author{} is non-empty → warn)
  • Search for institution names (university, lab, institute → warn)
  • Search for GitHub/GitLab links (may reveal identity → warn)
  • Search for "our previous work" / "we previously" → should use third-person citation
  • Search for \thanks{} / \acknowledgments → remove for anonymous submission

3c. [UNCONFIRMED] marker check:

# scan references.bib and all .tex files
grep -rn "VERIFY" paper/
  • If [UNCONFIRMED] markers exist: list each one; flag as submission blocker
  • Per citation-verification.md: [UNCONFIRMED] is a hard submission blocker

3d. Font embedding check:

pdffonts paper/main.pdf
  • Check the "emb" column: all fonts should be "yes"
  • Unembedded fonts: report font names; suggest adding font embedding to compile options

3e. Content completeness check:

  • Search for TODO, FIXME, XXX markers
  • Search for \missingfigure, empty sections (\section{X} followed by no content)
  • Search for unreferenced figures/tables (\includegraphics present but no \ref)
  • Check that the abstract exists and is non-empty

Step 4: Generate Submission Checklist and Report

# Compile Report

## Compilation
- Status: {SUCCESS / FAILED}
- Compiler: latexmk + pdflatex
- Rounds: {N} (including auto-fix rounds)
- Errors: {N} (fixed: {M}, remaining: {K})
- Warnings: {N} (overfull: {O}, underfull: {U}, other: {W})

## Verification Results

| Check | Status | Details |
|-------|--------|---------|
| Page count | {PASS/FAIL} | {N} pages (limit: {L}) |
| Anonymous | {PASS/WARN} | {details} |
| [UNCONFIRMED] citations | {PASS/FAIL} | {N} remaining |
| Fonts embedded | {PASS/FAIL} | {details} |
| No TODOs | {PASS/WARN} | {N} remaining |
| Figures referenced | {PASS/WARN} | {details} |
| Abstract present | {PASS/FAIL} | {details} |

## Submission Checklist

- [ ] PDF compiles without errors
- [ ] Page count within venue limit ({L} pages)
- [ ] All [UNCONFIRMED] citations resolved
- [ ] Anonymous submission (no author info)
- [ ] All fonts embedded
- [ ] No TODO/FIXME markers
- [ ] All figures referenced in text
- [ ] Abstract present and complete
- [ ] Supplementary material prepared (if applicable)
- [ ] Paper title matches submission system

## Blocking Issues
{list of FAIL items that must be resolved before submission}

## Warnings (non-blocking)
{list of WARN items for consideration}

## Next Steps
- {specific actions to resolve blocking issues}
- Run `/refine paper/main.tex --focus writing` for final polish
- Manual review of anonymous compliance

Append log:

python3 tools/research_wiki.py log wiki/ \
  "paper-compile | {SUCCESS/FAILED} | {pages} pages, {errors} errors, {verify_count} [UNCONFIRMED], {checks_passed}/{checks_total} checks passed"

Constraints

  • Do not modify wiki content: only operate on the paper/ directory and wiki/log.md
  • Auto-fix requires --fix: by default, only report errors; do not fix
  • [UNCONFIRMED] is a hard blocker: [UNCONFIRMED] present in submission checklist = not submittable
  • Maximum 3 fix-compile rounds: prevent infinite fix loops
  • Do not delete user content: auto-fix only adds or corrects; does not delete hand-written content
  • pdfinfo/pdffonts dependency: if not installed, skip the corresponding check and annotate "tool not available"
  • Anonymity check is heuristic: may produce false positives; annotate as WARN rather than FAIL

Error Handling

  • main.tex not found: error; suggest running /paper-draft first
  • latexmk not installed: error; provide installation command (sudo apt install texlive-full or brew install --cask mactex)
  • Compilation failed and auto-fix unsuccessful: output full error log + locate specific .tex file and line number
  • pdfinfo/pdffonts not installed: skip page count / font checks; annotate in report
  • PAPER_PLAN not found: skip venue info extraction; use default limit (10 pages); warn user
  • Permission issue (tlmgr requires sudo): report list of packages requiring manual installation

Dependencies

Tools(via Bash)

  • latexmk — LaTeX compilation
  • pdfinfo — PDF page count check (poppler-utils)
  • pdffonts — font embedding check (poppler-utils)
  • python3 tools/research_wiki.py log wiki/ "<message>" — append log

MCP Servers

  • None

Claude Code Native

  • Read — read .tex files and compilation logs
  • Edit — auto-fix .tex files (--fix mode)
  • Bash — execute compilation and check commands
  • Grep — search for [UNCONFIRMED], TODO, anonymity violations

Shared References

  • .claude/skills/shared-references/citation-verification.md — [UNCONFIRMED] marker check rules
  • .claude/skills/shared-references/academic-writing.md — venue page limit reference

Called by

  • /research Stage 5 (paper compilation stage)
  • Manual user invocation
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall