latex-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLaTeX Environment Setup
LaTeX环境搭建
You are helping a researcher set up or fix their LaTeX compilation environment. Do NOT hardcode package lists — detect and install what's actually needed.
你正在帮助研究人员搭建或修复他们的LaTeX编译环境。请勿硬编码包列表——检测并安装实际需要的组件。
Step 1: Detect Current State
步骤1:检测当前状态
Before installing anything:
-
Check installed TeX distribution:
which pdflatex && pdflatex --version which xelatex && xelatex --version which lualatex && lualatex --version -
Check bibliography processor:
which biber && biber --version which bibtex && bibtex --version -
Check package manager:
which tlmgr && tlmgr --version
在安装任何组件之前:
-
检查已安装的TeX发行版:
which pdflatex && pdflatex --version which xelatex && xelatex --version which lualatex && lualatex --version -
检查参考文献处理器:
which biber && biber --version which bibtex && bibtex --version -
检查包管理器:
which tlmgr && tlmgr --version
Step 2: Analyze the Project
步骤2:分析项目
Read the main .tex file to determine requirements:
- Document class: ,
\documentclass{article}, etc.\documentclass{IEEEtran} - Bibliography system:
- → needs
\usepackage{biblatex}biber - or
\usepackage{natbib}→ needs\bibliographystyle{...}bibtex
- Required packages: extract from all declarations
\usepackage{...} - Special requirements: TikZ, minted (needs pygments), algorithm2e, etc.
读取主.tex文件以确定需求:
- 文档类:、
\documentclass{article}等\documentclass{IEEEtran} - 参考文献系统:
- → 需要
\usepackage{biblatex}biber - 或
\usepackage{natbib}→ 需要\bibliographystyle{...}bibtex
- 所需包:从所有声明中提取
\usepackage{...} - 特殊需求:TikZ、minted(需要pygments)、algorithm2e等
Step 3: Venue Template Detection
步骤3:会议模板检测
If the user mentions a venue, search for the official template:
- Download from the venue's official website (NOT third-party mirrors)
- Check if the template specifies a required TeX distribution or class
- Note any venue-specific compilation instructions
Common venues and their requirements:
| Venue | Class | Bib system | Notes |
|---|---|---|---|
| CVPR/ECCV | Custom class file | bibtex | Usually provided in template |
| NeurIPS | neurips_20XX.sty | natbib + bibtex | Style file changes yearly |
| ICLR | iclr20XX_conference.sty | natbib + bibtex | OpenReview format |
| ACL/EMNLP | acl.cls | bibtex | ACL Anthology format |
| IEEE | IEEEtran.cls | bibtex | Column formatting specific |
| Springer | llncs.cls | bibtex or biblatex | Depends on series |
如果用户提到特定会议,搜索官方模板:
- 从会议官方网站下载(不要使用第三方镜像)
- 检查模板是否指定了所需的TeX发行版或文档类
- 记录任何会议特定的编译说明
常见会议及其要求:
| 会议/期刊 | 文档类 | 参考文献系统 | 说明 |
|---|---|---|---|
| CVPR/ECCV | 自定义类文件 | bibtex | 通常随模板提供 |
| NeurIPS | neurips_20XX.sty | natbib + bibtex | 样式文件每年更新 |
| ICLR | iclr20XX_conference.sty | natbib + bibtex | OpenReview格式 |
| ACL/EMNLP | acl.cls | bibtex | ACL Anthology格式 |
| IEEE | IEEEtran.cls | bibtex | 特定分栏格式 |
| Springer | llncs.cls | bibtex 或 biblatex | 取决于系列 |
Step 4: Install Missing Components
步骤4:安装缺失组件
Based on analysis, install only what's missing:
根据分析结果,仅安装缺失的组件:
On Ubuntu/Debian
在Ubuntu/Debian系统上
bash
undefinedbash
undefinedBase installation (if nothing installed)
基础安装(若未安装任何组件)
sudo apt install texlive-base texlive-latex-recommended
sudo apt install texlive-base texlive-latex-recommended
Common extras
常见扩展包
sudo apt install texlive-latex-extra # most \usepackage needs
sudo apt install texlive-fonts-recommended texlive-fonts-extra
sudo apt install texlive-bibtex-extra biber # if biblatex used
sudo apt install texlive-science # algorithm2e, etc.
undefinedsudo apt install texlive-latex-extra # 大多数\usepackage需求
sudo apt install texlive-fonts-recommended texlive-fonts-extra
sudo apt install texlive-bibtex-extra biber # 若使用biblatex
sudo apt install texlive-science # algorithm2e等
undefinedOn macOS
在macOS系统上
bash
undefinedbash
undefinedFull installation (recommended)
完整安装(推荐)
brew install --cask mactex
brew install --cask mactex
Minimal
极简安装
brew install --cask basictex
sudo tlmgr update --self
sudo tlmgr install <package-name>
undefinedbrew install --cask basictex
sudo tlmgr update --self
sudo tlmgr install <package-name>
undefinedIndividual packages via tlmgr
通过tlmgr安装单个包
bash
undefinedbash
undefinedIf specific packages are missing
若缺少特定包
sudo tlmgr install <package-name>
undefinedsudo tlmgr install <package-name>
undefinedStep 5: Configure Compilation
步骤5:配置编译
Set up the correct compilation pipeline:
设置正确的编译流程:
For bibtex projects
适用于bibtex项目
bash
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.texbash
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.texFor biblatex/biber projects
适用于biblatex/biber项目
bash
pdflatex main.tex
biber main
pdflatex main.tex
pdflatex main.texbash
pdflatex main.tex
biber main
pdflatex main.tex
pdflatex main.texCommon compilation issues
常见编译问题
- Missing .bib file: check path is correct
\bibliography{...} - Undefined citations: run bibtex/biber + pdflatex twice
- Missing packages: install via tlmgr, not apt (apt packages are coarse-grained)
- Font errors: install texlive-fonts-extra
- TikZ externalize errors: ensure write18 is enabled
- 缺少.bib文件:检查路径是否正确
\bibliography{...} - 引用未定义:运行bibtex/biber + pdflatex两次
- 缺少包:通过tlmgr安装,而非apt(apt包粒度较粗)
- 字体错误:安装texlive-fonts-extra
- TikZ外部化错误:确保write18已启用
Step 6: Verify Setup
步骤6:验证设置
After configuration:
- Run the full compilation pipeline
- Check the PDF opens correctly
- Verify bibliography entries appear
- Check for any remaining warnings in the .log file
配置完成后:
- 运行完整的编译流程
- 检查PDF能否正常打开
- 确认参考文献条目已显示
- 检查.log文件中是否有剩余警告
Output Format
输出格式
Produce:
- Current state: what's installed, what's missing
- Project requirements: detected from .tex files
- Installation commands: only what's needed, OS-specific
- Compilation command: the exact pipeline for this project
- Verification: confirm successful compilation
生成以下内容:
- 当前状态:已安装的组件和缺失的组件
- 项目需求:从.tex文件中检测到的需求
- 安装命令:仅安装所需组件,区分操作系统
- 编译命令:适用于该项目的具体流程
- 验证:确认编译成功