Skip to content

模块:编译

触发器:编译、编译、构建、pdflatex、xelatex

默认行为:使用 latexmk 自动处理所有依赖项(bibtex/biber、交叉引用、索引)并确定最佳编译遍数。这是大多数用例的推荐方法。

工具(配套VS Code LaTeX Workshop):

工具命令参数
赛拉泰克斯xelatex-synctex=1 -interaction=nonstopmode -file-line-error
pdf乳胶pdflatex-synctex=1 -interaction=nonstopmode -file-line-error
乳胶latexmk-synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=%OUTDIR%
比布克斯bibtex%DOCFILE%
比伯biber%DOCFILE%

食谱

食谱步骤使用案例
乳胶LatexMK(自动)默认 - 自动处理所有依赖项
PDFLaTeXpdf乳胶快速单通道构建
XeLaTeX赛拉泰克斯快速单通道构建
pdflatex -> bibtex -> pdflatex*2pdflatex → bibtex → pdflatex → pdflatex传统 BibTeX 工作流程
pdflatex -> biber -> pdflatex*2pdflatex → biber → pdflatex → pdflatex现代 biblatex(推荐用于新项目)
xelatex -> bibtex -> xelatex*2xelatex → bibtex → xelatex → xelatex中文/Unicode + BibTeX
xelatex -> biber -> xelatex*2xelatex → biber → xelatex → xelatex中文/Unicode + biblatex

用法

bash
# Default: latexmk auto-handles all dependencies (recommended)
uv run python -B scripts/compile.py main.tex                          # Auto-detect compiler + latexmk

# Single-pass compilation (quick builds)
uv run python -B scripts/compile.py main.tex --recipe pdflatex        # PDFLaTeX only
uv run python -B scripts/compile.py main.tex --recipe xelatex         # XeLaTeX only

# Explicit bibliography workflows (when you need control)
uv run python -B scripts/compile.py main.tex --recipe pdflatex-bibtex # Traditional BibTeX
uv run python -B scripts/compile.py main.tex --recipe pdflatex-biber  # Modern biblatex (recommended)
uv run python -B scripts/compile.py main.tex --recipe xelatex-bibtex  # XeLaTeX + BibTeX
uv run python -B scripts/compile.py main.tex --recipe xelatex-biber   # XeLaTeX + biblatex

# With output directory
uv run python -B scripts/compile.py main.tex --outdir build

# Force detected-compiler biber workflow
uv run python -B scripts/compile.py main.tex --biber

# Utilities
uv run python -B scripts/compile.py main.tex --watch                  # Watch mode
uv run python -B scripts/compile.py main.tex --clean                  # Clean aux files
uv run python -B scripts/compile.py main.tex --clean-all              # Clean all (incl. PDF)

自动检测:脚本检测中文内容(ctex、xeCJK、中文字符)并自动选择 xelatex。

基于 MIT 许可发布