paper-compilation

paper-compilation

热门

将 LaTeX 论文编译为 PDF,具备自动错误检测、chktex 风格检查和引文/参考文献验证功能。运行完整的 pdflatex + bibtex 流水线。当用户想要编译论文、修复编译错误或调试 LaTeX 时使用。

299Star
37Fork
更新于 2026/2/27
SKILL.md
只读
名称
paper-compilation
描述

将 LaTeX 论文编译为 PDF,具备自动错误检测、chktex 风格检查和引文/参考文献验证功能。运行完整的 pdflatex + bibtex 流水线。当用户想要编译论文、修复编译错误或调试 LaTeX 时使用。

论文编译

将 LaTeX 论文编译为 PDF,并具备错误检测和修正功能。

输入

  • $ARGUMENTS — 主 .tex 文件的路径

脚本

编译论文

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

报告:编译状态、页数、警告、引文/参考文献统计、风格问题。

编译前验证引文

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

自动修复 LaTeX 错误

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

带自动修复重试的编译

python ~/.claude/skills/paper-compilation/scripts/compile_paper.py paper/main.tex --auto-fix

运行 fix_latex_errors.py 并重新编译,最多重试 3 轮,直到编译成功。

工作流程

第 1 步:编译前验证

运行 validate_citations.py 以在编译前发现问题:

  • 每个 \cite{key} 都有对应的 .bib 条目
  • 每个 \includegraphics{file} 都存在
  • 没有重复的标签或章节

第 2 步:编译

运行 compile_paper.py,它执行:pdflatex → bibtex → pdflatex → pdflatex

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

如果编译失败,读取错误输出并修正:

  • ! Undefined control sequence → 添加缺失的宏包或修正拼写错误
  • ! Missing $ inserted → 将数学内容用 $...$ 括起来
  • ! Missing } inserted → 修复不匹配的花括号
  • Citation 'key' undefined → 添加到 .bib 或修正 \cite
  • </end{figure}> → 替换为 \end{figure}(LaTeX 中的 HTML 语法)

应用最小修复。不要无故删除宏包。每次修复后重新编译。

第 4 步:编译后报告

检查:页数是否符合会议限制、剩余警告、chktex 风格问题。

故障排除

找不到 pdflatex

# macOS
brew install --cask mactex-no-gui
# Ubuntu
sudo apt install texlive-full

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

latexmk -pdf -interaction=nonstopmode main.tex

相关技能