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






