paper-compile

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Paper Compile: LaTeX to Submission-Ready PDF

论文编译:将LaTeX转换为可投稿PDF

Compile the LaTeX paper and fix any issues: $ARGUMENTS
编译LaTeX论文并修复所有问题:$ARGUMENTS

Constants

常量定义

  • COMPILER =
    latexmk
    — LaTeX build tool. Handles multi-pass compilation automatically.
  • ENGINE =
    pdflatex
    — LaTeX engine. Options:
    pdflatex
    (default),
    xelatex
    (for CJK/custom fonts),
    lualatex
    .
  • MAX_COMPILE_ATTEMPTS = 3 — Maximum attempts to fix errors and recompile.
  • PAPER_DIR =
    paper/
    — Directory containing LaTeX source files.
  • MAX_PAGES — Main body page limit (to end of Conclusion, excluding references & appendix). ICLR=9, NeurIPS=9, ICML=8.
  • COMPILER =
    latexmk
    — LaTeX构建工具,可自动处理多轮编译。
  • ENGINE =
    pdflatex
    — LaTeX引擎,可选值:
    pdflatex
    (默认)、
    xelatex
    (适用于CJK/自定义字体)、
    lualatex
  • MAX_COMPILE_ATTEMPTS = 3 — 修复错误并重编译的最大尝试次数。
  • PAPER_DIR =
    paper/
    — 存放LaTeX源文件的目录。
  • MAX_PAGES — 主体内容页数限制(从首页到结论部分结束,不包含参考文献和附录)。ICLR=9页,NeurIPS=9页,ICML=8页。

Workflow

工作流程

Step 1: Verify Prerequisites

步骤1:验证前置条件

Check that the compilation environment is ready:
bash
undefined
检查编译环境是否就绪:
bash
undefined

Check LaTeX installation

检查LaTeX是否安装

which pdflatex && which latexmk && which bibtex
which pdflatex && which latexmk && which bibtex

If not installed, provide instructions:

若未安装,提供以下安装说明:

macOS: brew install --cask mactex-no-gui

macOS:brew install --cask mactex-no-gui

Ubuntu: sudo apt-get install texlive-full

Ubuntu:sudo apt-get install texlive-full

Server: conda install -c conda-forge texlive-core

服务器环境:conda install -c conda-forge texlive-core


Verify all required files exist:

```bash

验证所有必要文件是否存在:

```bash

Must exist

必须存在的文件

ls $PAPER_DIR/main.tex
ls $PAPER_DIR/main.tex

Should exist

建议存在的文件

ls $PAPER_DIR/references.bib ls $PAPER_DIR/sections/.tex ls $PAPER_DIR/figures/.pdf 2>/dev/null || ls $PAPER_DIR/figures/*.png 2>/dev/null
undefined
ls $PAPER_DIR/references.bib ls $PAPER_DIR/sections/.tex ls $PAPER_DIR/figures/.pdf 2>/dev/null || ls $PAPER_DIR/figures/*.png 2>/dev/null
undefined

Step 2: First Compilation Attempt

步骤2:首次编译尝试

bash
cd $PAPER_DIR
bash
cd $PAPER_DIR

Clean previous build artifacts

清理之前的构建产物

latexmk -C
latexmk -C

Full compilation (pdflatex + bibtex + pdflatex × 2)

完整编译流程(pdflatex + bibtex + pdflatex × 2)

latexmk -pdf -interaction=nonstopmode -halt-on-error main.tex 2>&1 | tee compile.log
undefined
latexmk -pdf -interaction=nonstopmode -halt-on-error main.tex 2>&1 | tee compile.log
undefined

Step 3: Error Diagnosis and Auto-Fix

步骤3:错误诊断与自动修复

If compilation fails, read
compile.log
and fix common errors:
Missing packages:
! LaTeX Error: File `somepackage.sty' not found.
→ Install via
tlmgr install somepackage
or remove the
\usepackage
if unused.
Undefined references:
LaTeX Warning: Reference `fig:xyz' on page 3 undefined
→ Check
\label{fig:xyz}
exists in the correct figure environment.
Missing figures:
! LaTeX Error: File `figures/fig1.pdf' not found.
→ Check if the file exists with a different extension (.png vs .pdf). Update the
\includegraphics
path.
Citation undefined:
LaTeX Warning: Citation `smith2024' undefined
→ Add the missing entry to
references.bib
or fix the citation key.
[VERIFY]
markers in text:
→ Search for
[VERIFY]
markers left by
/paper-write
. These indicate unverified citations or facts. Search for the correct information or flag to the user.
Overfull hbox:
Overfull \hbox (12.5pt too wide) in paragraph at lines 42--45
→ Minor: usually ignorable. If severe (>20pt), rephrase the text or adjust figure width.
BibTeX errors:
I was expecting a `,' or a `}'---line 15 of references.bib
→ Fix BibTeX syntax (missing comma, unmatched braces, special characters in title).
\crefname
undefined for custom theorem types:
→ Ensure
\crefname{assumption}{Assumption}{Assumptions}
and similar are in the preamble after
\newtheorem{assumption}
.
若编译失败,读取
compile.log
并修复常见错误:
缺失包:
! LaTeX Error: File `somepackage.sty' not found.
→ 通过
tlmgr install somepackage
安装该包,若未使用则移除
\usepackage
语句。
未定义引用:
LaTeX Warning: Reference `fig:xyz' on page 3 undefined
→ 检查
\label{fig:xyz}
是否存在于正确的图片环境中。
缺失图片:
! LaTeX Error: File `figures/fig1.pdf' not found.
→ 检查文件是否存在,是否使用了其他扩展名(.png vs .pdf),更新
\includegraphics
的路径。
未定义引用文献:
LaTeX Warning: Citation `smith2024' undefined
→ 在
references.bib
中添加缺失的条目,或修正引用键。
文本中存在
[VERIFY]
标记:
→ 搜索由
/paper-write
留下的
[VERIFY]
标记,这些标记表示引用或事实未经验证。查找正确信息或告知用户。
行宽溢出(Overfull hbox):
Overfull \hbox (12.5pt too wide) in paragraph at lines 42--45
→ 轻微问题:通常可忽略。若严重(>20pt),则改写文本或调整图片宽度。
BibTeX错误:
I was expecting a `,' or a `}'---line 15 of references.bib
→ 修复BibTeX语法(缺失逗号、未匹配的大括号、标题中的特殊字符)。
自定义定理类型的
\crefname
未定义:
→ 确保在
\newtheorem{assumption}
之后的导言区中添加
\crefname{assumption}{Assumption}{Assumptions}
及类似语句。

Step 4: Iterative Fix Loop

步骤4:迭代修复循环

for attempt in 1..MAX_COMPILE_ATTEMPTS:
    compile()
    if success:
        break
    parse_errors()
    auto_fix()
For each error:
  1. Read the error message from
    compile.log
  2. Locate the source file and line number
  3. Apply the fix
  4. Recompile
for attempt in 1..MAX_COMPILE_ATTEMPTS:
    compile()
    if success:
        break
    parse_errors()
    auto_fix()
针对每个错误:
  1. compile.log
    中读取错误信息
  2. 定位源文件和行号
  3. 应用修复方案
  4. 重新编译

Step 5: Post-Compilation Checks

步骤5:编译后检查

After successful compilation, verify the output:
bash
undefined
编译成功后,验证输出结果:
bash
undefined

Check PDF exists and has content

检查PDF是否存在且有内容

ls -la main.pdf
ls -la main.pdf

Check page count

检查页数

pdfinfo main.pdf | grep Pages
pdfinfo main.pdf | grep Pages

macOS: open for visual inspection

macOS系统:打开PDF进行视觉检查

open main.pdf

open main.pdf


**Automated checks:**

- [ ] PDF file exists and is > 100KB (not empty/corrupt)
- [ ] Total page count is reasonable (MAX_PAGES + appendix + references)
- [ ] No "??" in the PDF (undefined references — grep the log)
- [ ] No "[?]" in the PDF (undefined citations — grep the log)
- [ ] Figures are rendered (not missing image placeholders)

```bash

**自动化检查:**

- [ ] PDF文件存在且大小>100KB(非空/未损坏)
- [ ] 总页数合理(MAX_PAGES + 附录 + 参考文献)
- [ ] PDF中无"??"(未定义引用——查看日志)
- [ ] PDF中无"[?]"(未定义文献引用——查看日志)
- [ ] 图片已渲染(无缺失图片占位符)

```bash

Check for undefined references

检查未定义引用

grep -c "LaTeX Warning.*undefined" compile.log
grep -c "LaTeX Warning.*undefined" compile.log

Check for missing citations

检查缺失的文献引用

grep -c "Citation.*undefined" compile.log
undefined
grep -c "Citation.*undefined" compile.log
undefined

Step 6: Page Count Verification

步骤6:页数验证

CRITICAL: Verify main body fits within MAX_PAGES.
Main body = first page through end of Conclusion section (not necessarily §5 — could be §6, §7, or §8 depending on structure). References and appendix are NOT counted.
Precise check using
pdftotext
:
bash
undefined
关键检查:验证主体内容是否在MAX_PAGES限制内。
主体内容 = 首页到结论部分结束(不一定是第5节——可能是第6、7或8节,取决于结构)。参考文献和附录不计入。
使用
pdftotext
进行精确检查:
bash
undefined

Extract text and find where Conclusion ends vs References begin

提取文本并查找结论结束和参考文献开始的位置

pdftotext main.pdf - | python3 -c " import sys text = sys.stdin.read() pages = text.split('\f') for i, page in enumerate(pages): if 'Ethics Statement' in page or 'Reproducibility' in page: print(f'Conclusion ends on page {i+1}') if any(w in page for w in ['References', 'Bibliography']): lines = [l for l in page.split('\n') if l.strip()] for l in lines[:3]: if 'References' in l or 'Bibliography' in l: print(f'References start on page {i+1}') break "

If Conclusion ends mid-page and References start on the same page, the main body is that page number (e.g., if both are on page 9, main body = ~8.5 pages, which is fine for a 9-page limit since it leaves room for the References header).

If over limit:
- Identify which sections are longest
- Suggest specific cuts (move proofs to appendix, compress tables, tighten writing)
- Report: "Main body is X pages (limit: MAX_PAGES). Suggestion: move [specific content] to appendix."
pdftotext main.pdf - | python3 -c " import sys text = sys.stdin.read() pages = text.split('\f') for i, page in enumerate(pages): if 'Ethics Statement' in page or 'Reproducibility' in page: print(f'结论结束于第 {i+1} 页') if any(w in page for w in ['References', 'Bibliography']): lines = [l for l in page.split('\n') if l.strip()] for l in lines[:3]: if 'References' in l or 'Bibliography' in l: print(f'参考文献开始于第 {i+1} 页') break "

若结论在某页中间结束,且参考文献从同一页开始,则主体内容页数为该页码(例如,若两者都在第9页,则主体内容约为8.5页,符合9页限制,因为参考文献标题需要预留空间)。

若超出限制:
- 找出最长的章节
- 建议具体的删减方案(将证明移至附录、压缩表格、精简文字)
- 报告:“主体内容为X页(限制:MAX_PAGES)。建议:将[具体内容]移至附录。”

Step 6.5: Stale File Detection

步骤6.5:检测过时文件

Check for orphaned section files not referenced by
main.tex
:
bash
undefined
检查
main.tex
未引用的孤立章节文件:
bash
undefined

Find all .tex files in sections/ and check which are \input'ed by main.tex

找出sections/下所有.tex文件,检查哪些未被main.tex引用

for f in paper/sections/*.tex; do base=$(basename "$f") if ! grep -q "$base" paper/main.tex; then echo "WARNING: $f is not referenced by main.tex — consider removing" fi done

This prevents confusion from leftover files when section structure changes (e.g., old `5_conclusion.tex` left behind after restructuring to 7 sections).
for f in paper/sections/*.tex; do base=$(basename "$f") if ! grep -q "$base" paper/main.tex; then echo "警告:$f 未被main.tex引用——考虑删除" fi done

这可避免章节结构变更后遗留文件造成混淆(例如,章节结构调整为7节后,遗留旧文件`5_conclusion.tex`)。

Step 7: Submission Readiness

步骤7:投稿就绪检查

For conference submission, additional checks:
  • Anonymous: no author names, affiliations, or self-citations that reveal identity
  • Page limit: main body within MAX_PAGES (to end of Conclusion)
  • Font embedding: all fonts embedded in PDF
    bash
    pdffonts main.pdf | grep -v "yes"  # should return nothing (or only header)
  • No supplementary mixed in: appendix clearly after
    \newpage\appendix
  • File size: reasonable (< 50MB for most venues, < 10MB preferred)
  • No
    [VERIFY]
    markers
    : search the PDF text for leftover markers
针对会议投稿,需额外检查:
  • 匿名性:无作者姓名、机构或可暴露身份的自引
  • 页数限制:主体内容在MAX_PAGES内(到结论结束)
  • 字体嵌入:所有字体已嵌入PDF
    bash
    pdffonts main.pdf | grep -v "yes"  # 应无输出(仅表头除外)
  • 无混入补充内容:附录明确位于
    \newpage\appendix
    之后
  • 文件大小:合理(大多数会议<50MB,建议<10MB)
  • [VERIFY]
    标记
    :在PDF文本中搜索遗留的标记

Step 8: Output Summary

步骤8:输出总结

markdown
undefined
markdown
undefined

Compilation Report

编译报告

  • Status: SUCCESS / FAILED
  • PDF: paper/main.pdf
  • Pages: X (main body to Conclusion) + Y (references) + Z (appendix)
  • Within page limit: YES/NO (MAX_PAGES = N)
  • Errors fixed: [list of auto-fixed issues]
  • Warnings remaining: [list of non-critical warnings]
  • Undefined references: 0
  • Undefined citations: 0
  • 状态:成功/失败
  • PDF文件:paper/main.pdf
  • 页数:X(主体内容到结论) + Y(参考文献) + Z(附录)
  • 是否符合页数限制:是/否(MAX_PAGES = N)
  • 已修复错误:[自动修复的问题列表]
  • 剩余警告:[非关键警告列表]
  • 未定义引用:0
  • 未定义文献引用:0

Next Steps

后续步骤

  • Visual inspection of PDF
  • Run
    /paper-write
    to fix any content issues
  • Submit to [venue] via OpenReview / CMT / HotCRP
undefined
  • 视觉检查PDF
  • 运行
    /paper-write
    修复内容问题
  • 通过OpenReview / CMT / HotCRP提交至[会议]
undefined

Key Rules

核心规则

  • Never delete the user's source files — only modify to fix errors
  • Keep compile.log — useful for debugging
  • Don't suppress warnings — report them, let the user decide
  • If LaTeX is not installed, provide clear installation instructions rather than failing silently
  • Font embedding is critical — some venues reject PDFs with non-embedded fonts
  • Page count = main body to Conclusion — this is the metric that matters for submission
  • 切勿删除用户的源文件——仅修改以修复错误
  • 保留compile.log——便于调试
  • 不要抑制警告——报告警告,由用户决定是否处理
  • 若未安装LaTeX——提供清晰的安装说明,而非静默失败
  • 字体嵌入至关重要——部分会议会拒绝未嵌入字体的PDF
  • 页数统计 = 主体内容到结论结束——这是投稿的关键指标

Common Venue Requirements

常见会议要求

VenueStyle FileCitationPage Limit (main body)Submission
ICLR 2026
iclr2026_conference.sty
natbib
(
\citep
/
\citet
)
9 pages (to Conclusion end)OpenReview
NeurIPS 2025
neurips_2025.sty
natbib
(
\citep
/
\citet
)
9 pages (to Conclusion end)OpenReview
ICML 2025
icml2025.sty
natbib
(
\citep
/
\citet
)
8 pages (to Conclusion end)OpenReview
会议样式文件引用格式主体内容页数限制投稿平台
ICLR 2026
iclr2026_conference.sty
natbib
\citep
/
\citet
9页(到结论结束)OpenReview
NeurIPS 2025
neurips_2025.sty
natbib
\citep
/
\citet
9页(到结论结束)OpenReview
ICML 2025
icml2025.sty
natbib
\citep
/
\citet
8页(到结论结束)OpenReview