latex-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LaTeX 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:
  1. Check installed TeX distribution:
    which pdflatex && pdflatex --version
    which xelatex && xelatex --version
    which lualatex && lualatex --version
  2. Check bibliography processor:
    which biber && biber --version
    which bibtex && bibtex --version
  3. Check package manager:
    which tlmgr && tlmgr --version
在安装任何组件之前:
  1. 检查已安装的TeX发行版:
    which pdflatex && pdflatex --version
    which xelatex && xelatex --version
    which lualatex && lualatex --version
  2. 检查参考文献处理器:
    which biber && biber --version
    which bibtex && bibtex --version
  3. 检查包管理器:
    which tlmgr && tlmgr --version

Step 2: Analyze the Project

步骤2:分析项目

Read the main .tex file to determine requirements:
  1. Document class:
    \documentclass{article}
    ,
    \documentclass{IEEEtran}
    , etc.
  2. Bibliography system:
    • \usepackage{biblatex}
      → needs
      biber
    • \usepackage{natbib}
      or
      \bibliographystyle{...}
      → needs
      bibtex
  3. Required packages: extract from all
    \usepackage{...}
    declarations
  4. Special requirements: TikZ, minted (needs pygments), algorithm2e, etc.
读取主.tex文件以确定需求:
  1. 文档类:
    \documentclass{article}
    、
    \documentclass{IEEEtran}
    等
  2. 参考文献系统:
    • \usepackage{biblatex}
      → 需要
      biber
    • \usepackage{natbib}
      或
      \bibliographystyle{...}
      → 需要
      bibtex
  3. 所需包:从所有
    \usepackage{...}
    声明中提取
  4. 特殊需求: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:
VenueClassBib systemNotes
CVPR/ECCVCustom class filebibtexUsually provided in template
NeurIPSneurips_20XX.stynatbib + bibtexStyle file changes yearly
ICLRiclr20XX_conference.stynatbib + bibtexOpenReview format
ACL/EMNLPacl.clsbibtexACL Anthology format
IEEEIEEEtran.clsbibtexColumn formatting specific
Springerllncs.clsbibtex or biblatexDepends on series
如果用户提到特定会议,搜索官方模板:
  • 从会议官方网站下载(不要使用第三方镜像)
  • 检查模板是否指定了所需的TeX发行版或文档类
  • 记录任何会议特定的编译说明
常见会议及其要求:
会议/期刊文档类参考文献系统说明
CVPR/ECCV自定义类文件bibtex通常随模板提供
NeurIPSneurips_20XX.stynatbib + bibtex样式文件每年更新
ICLRiclr20XX_conference.stynatbib + bibtexOpenReview格式
ACL/EMNLPacl.clsbibtexACL Anthology格式
IEEEIEEEtran.clsbibtex特定分栏格式
Springerllncs.clsbibtex 或 biblatex取决于系列

Step 4: Install Missing Components

步骤4:安装缺失组件

Based on analysis, install only what's missing:
根据分析结果,仅安装缺失的组件:

On Ubuntu/Debian

在Ubuntu/Debian系统上

bash
undefined
bash
undefined

Base 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.
undefined
sudo 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等
undefined

On macOS

在macOS系统上

bash
undefined
bash
undefined

Full installation (recommended)

完整安装(推荐)

brew install --cask mactex
brew install --cask mactex

Minimal

极简安装

brew install --cask basictex sudo tlmgr update --self sudo tlmgr install <package-name>
undefined
brew install --cask basictex sudo tlmgr update --self sudo tlmgr install <package-name>
undefined

Individual packages via tlmgr

通过tlmgr安装单个包

bash
undefined
bash
undefined

If specific packages are missing

若缺少特定包

sudo tlmgr install <package-name>
undefined
sudo tlmgr install <package-name>
undefined

Step 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.tex
bash
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex

For biblatex/biber projects

适用于biblatex/biber项目

bash
pdflatex main.tex
biber main
pdflatex main.tex
pdflatex main.tex
bash
pdflatex main.tex
biber main
pdflatex main.tex
pdflatex main.tex

Common compilation issues

常见编译问题

  • Missing .bib file: check
    \bibliography{...}
    path is correct
  • 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:
  1. Run the full compilation pipeline
  2. Check the PDF opens correctly
  3. Verify bibliography entries appear
  4. Check for any remaining warnings in the .log file
配置完成后:
  1. 运行完整的编译流程
  2. 检查PDF能否正常打开
  3. 确认参考文献条目已显示
  4. 检查.log文件中是否有剩余警告

Output Format

输出格式

Produce:
  1. Current state: what's installed, what's missing
  2. Project requirements: detected from .tex files
  3. Installation commands: only what's needed, OS-specific
  4. Compilation command: the exact pipeline for this project
  5. Verification: confirm successful compilation
生成以下内容:
  1. 当前状态:已安装的组件和缺失的组件
  2. 项目需求:从.tex文件中检测到的需求
  3. 安装命令:仅安装所需组件,区分操作系统
  4. 编译命令:适用于该项目的具体流程
  5. 验证:确认编译成功