compile-latex
Use when compiling a LaTeX paper, debugging LaTeX errors, building a paper PDF, or when a .tex file fails to produce output. Handles engine detectio…
它会碰到什么
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
Compile LaTeX
Overview
This skill compiles LaTeX documents correctly with the right engine and bibliography system, handles multi-pass compilation, and parses errors to suggest fixes. It ships with a wrapper script (scripts/compile.sh) that detects everything automatically and can be invoked directly.
When to Use
- Compiling any
.texfile - "The paper won't compile"
- LaTeX error messages appearing in output
- Generating the final PDF for submission
- CI or automated builds of a paper
- Verifying that cross-references and citations resolve correctly
Mandatory Steps
- Detect the engine from the preamble. Look for
\usepackage{fontspec}. If present, usexelatex. Otherwise usepdflatex. The wrapper script does this automatically.
- Detect the bibliography system.
\usepackage{biblatex}in the preamble implies biber.\bibliography{...}at the end of the document implies bibtex. Neither implies no bibliography pass.
- Prefer
latexmkif available. It handles multi-pass logic automatically and is more robust than running passes manually.
- If
latexmkis unavailable, run the manual sequence: engine → bib (if applicable) → engine → engine.
- On error, parse the log file (
<base>.log). Extract lines starting with!, report the line number and file, and suggest a likely fix from the error table below.
- Verify the PDF was produced after successful compilation and that it is non-empty.
Using the Wrapper Script
Invoke the compile script directly:
./skills/compile-latex/scripts/compile.sh paper/paper.tex
The script detects engine and bibliography system, runs latexmk if available, falls back to manual multi-pass otherwise, and exits non-zero on failure. All detection and pass logic is handled internally — no flags needed beyond the path to the .tex file.
Common Errors and Fixes
| Error | Cause | Fix |
|-------|-------|-----|
| Undefined control sequence \foo | Missing package | Add \usepackage{pkg} providing \foo |
| File 'x.sty' not found | Missing package | Install TeX package (tlmgr install x) |
| Citation 'X' undefined | Bib pass not run | Run biber or bibtex, then re-run engine |
| Missing \begin{document} | Preamble typo | Check brace balance in preamble |
| Package fontspec Error | Used pdflatex instead of xelatex | Switch engine |
| Overfull \hbox | Typographical warning | Usually safe to ignore, or rephrase the offending line |
| LaTeX Error: File 'x.tex' not found | Missing \input{} target | Verify path relative to the main file |
Anti-Patterns
- Running
pdflatexon a document that needsxelatex - Ignoring
Citation undefinedwarnings — they mean the bibliography is broken - Single-pass compilation when cross-references exist (
\ref,\cite,\label) - Committing
.aux,.log,.bbl,.out,.toc,.fls,.fdb_latexmkauxiliary files to git - Ignoring errors and just "running it again" until it compiles
Verification Before Completion
- [ ] Engine detected matches preamble requirements
- [ ] Bibliography system correctly identified
- [ ] Multi-pass executed when needed (engine → bib → engine → engine)
- [ ] Exit code 0 from the compile step
- [ ]
<base>.pdfexists and is non-empty - [ ] No
Undefinedwarnings in the final log - [ ] Auxiliary files not staged in git
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。
它属于哪个仓库
skills/60-regisely-superpapers/skills/compile-latex/SKILL.md同一个仓库里的其他技能
- Full-empirical-analysis-skill
- Full-empirical-analysis-skill-R
- Full-empirical-analysis-skill-Stata
- auto-empirical-research-skills
- StatsPAI_skill
- Full-empirical-analysis-skill
- Full-empirical-analysis-skill-Stata
- Full-empirical-analysis-skill-R
- academic-paper-composer
- academic-paper-strategist
- medical-imaging-review
- paper-slide-deck
同名技能的其他版本
有 3 个不同仓库或目录里都有叫 compile-latex 的技能。它们内容并不相同,别混用:
- brycewang-stanford/Auto-Empirical-Research-Skills — Compile a Beamer LaTeX slide deck with XeLaTeX (3 passes + bibtex). Use when compiling lec
- brycewang-stanford/Auto-Empirical-Research-Skills — Compile a LaTeX manuscript with pdflatex (3 passes + bibtex). Use when compiling the resea