paper-compilation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Paper Compilation

论文编译

Compile a LaTeX paper to PDF with error detection and correction.
将LaTeX论文编译为PDF,同时进行错误检测与修正。

Input

输入

  • $ARGUMENTS
    — Path to the main
    .tex
    file
  • $ARGUMENTS
    — 主
    .tex
    文件的路径

Scripts

脚本

Compile paper

编译论文

bash
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --check-style
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --output paper/output.pdf
Reports: compilation status, page count, warnings, citation/reference stats, style issues.
bash
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --check-style
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --output paper/output.pdf
输出内容包括:编译状态、页数、警告信息、引用/参考文献统计数据、样式问题。

Validate citations before compiling

编译前验证引用

bash
python ~/.claude/skills/citation-management/scripts/validate_citations.py \
  --tex paper/main.tex --bib paper/references.bib --check-figures --figures-dir paper/figures/
bash
python ~/.claude/skills/citation-management/scripts/validate_citations.py \
  --tex paper/main.tex --bib paper/references.bib --check-figures --figures-dir paper/figures/

Auto-fix LaTeX errors

自动修复LaTeX错误

bash
python ~/.claude/skills/paper-compilation/scripts/fix_latex_errors.py \
  --tex paper/main.tex --log compile.log --output paper/main_fixed.tex
Fixes: HTML tags in LaTeX, mismatched environments, missing figures. Key flags:
--dry-run
,
--auto-detect
bash
python ~/.claude/skills/paper-compilation/scripts/fix_latex_errors.py \
  --tex paper/main.tex --log compile.log --output paper/main_fixed.tex
可修复问题:LaTeX中的HTML标签、不匹配的环境、缺失的图片。关键参数:
--dry-run
--auto-detect

Compile with auto-fix retry

自动修复后重试编译

bash
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --auto-fix
Runs fix_latex_errors.py + recompile up to 3 rounds until compilation succeeds.
bash
python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --auto-fix
运行fix_latex_errors.py + 重新编译,最多尝试3轮直到编译成功。

Workflow

工作流程

Step 1: Pre-Compilation Validation

步骤1:编译前验证

Run
validate_citations.py
to catch issues before compiling:
  • Every
    \cite{key}
    has a matching
    .bib
    entry
  • Every
    \includegraphics{file}
    exists
  • No duplicate labels or sections
运行
validate_citations.py
在编译前排查问题:
  • 每个
    \cite{key}
    .bib
    文件中都有对应的条目
  • 每个
    \includegraphics{file}
    对应的文件存在
  • 无重复标签或章节

Step 2: Compile

步骤2:编译

Run
compile_paper.py
which executes:
pdflatex → bibtex → pdflatex → pdflatex
运行
compile_paper.py
,执行流程:
pdflatex → bibtex → pdflatex → pdflatex

Step 3: Error Correction Loop (up to 5 rounds)

步骤3:错误修正循环(最多5轮)

If compilation fails, read the error output and fix:
  • ! Undefined control sequence
    → Add missing package or fix typo
  • ! Missing $ inserted
    → Wrap math in
    $...$
  • ! Missing } inserted
    → Fix unmatched brace
  • Citation 'key' undefined
    → Add to .bib or fix
    \cite
  • </end{figure}>
    → Replace with
    \end{figure}
    (HTML syntax in LaTeX)
Apply minimal fixes. Do not remove packages unnecessarily. Recompile after each fix.
如果编译失败,读取错误输出并修复:
  • ! Undefined control sequence
    → 添加缺失的包或修正拼写错误
  • ! Missing $ inserted
    → 用
    $...$
    包裹数学公式
  • ! Missing } inserted
    → 修复不匹配的大括号
  • Citation 'key' undefined
    → 添加到.bib文件或修正
    \cite
    命令
  • </end{figure}>
    → 替换为
    \end{figure}
    (LaTeX中的HTML语法问题)
应用最小化修复,不要随意移除包。每次修复后重新编译。

Step 4: Post-Compilation Report

步骤4:编译后报告

Check: page count vs venue limit, remaining warnings, chktex style issues.
检查:页数是否符合会议/期刊限制、剩余警告信息、chktex样式问题。

Troubleshooting

故障排除

pdflatex not found

未找到pdflatex

bash
undefined
bash
undefined

macOS

macOS

brew install --cask mactex-no-gui
brew install --cask mactex-no-gui

Ubuntu

Ubuntu

sudo apt install texlive-full
undefined
sudo apt install texlive-full
undefined

Alternative: latexmk (auto-handles multiple passes)

替代方案:latexmk(自动处理多轮编译)

bash
latexmk -pdf -interaction=nonstopmode main.tex
bash
latexmk -pdf -interaction=nonstopmode main.tex

Related Skills

相关技能

  • Upstream: latex-formatting, citation-management, figure-generation, table-generation
  • Downstream: self-review
  • See also: paper-assembly
  • 上游:latex-formattingcitation-managementfigure-generationtable-generation
  • 下游:self-review
  • 另见:paper-assembly