paper-compile
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePaper Compile: LaTeX to Submission-Ready PDF
论文编译:将LaTeX转换为可投稿PDF
Compile the LaTeX paper and fix any issues: $ARGUMENTS
编译LaTeX论文并修复所有问题:$ARGUMENTS
Constants
常量定义
- COMPILER = — LaTeX build tool. Handles multi-pass compilation automatically.
latexmk - ENGINE = — LaTeX engine. Options:
pdflatex(default),pdflatex(for CJK/custom fonts),xelatex.lualatex - MAX_COMPILE_ATTEMPTS = 3 — Maximum attempts to fix errors and recompile.
- PAPER_DIR = — Directory containing LaTeX source files.
paper/ - MAX_PAGES — Main body page limit (to end of Conclusion, excluding references & appendix). ICLR=9, NeurIPS=9, ICML=8.
- COMPILER = — LaTeX构建工具,可自动处理多轮编译。
latexmk - ENGINE = — LaTeX引擎,可选值:
pdflatex(默认)、pdflatex(适用于CJK/自定义字体)、xelatex。lualatex - MAX_COMPILE_ATTEMPTS = 3 — 修复错误并重编译的最大尝试次数。
- PAPER_DIR = — 存放LaTeX源文件的目录。
paper/ - MAX_PAGES — 主体内容页数限制(从首页到结论部分结束,不包含参考文献和附录)。ICLR=9页,NeurIPS=9页,ICML=8页。
Workflow
工作流程
Step 1: Verify Prerequisites
步骤1:验证前置条件
Check that the compilation environment is ready:
bash
undefined检查编译环境是否就绪:
bash
undefinedCheck 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
验证所有必要文件是否存在:
```bashMust 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
undefinedls $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
undefinedStep 2: First Compilation Attempt
步骤2:首次编译尝试
bash
cd $PAPER_DIRbash
cd $PAPER_DIRClean 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
undefinedlatexmk -pdf -interaction=nonstopmode -halt-on-error main.tex 2>&1 | tee compile.log
undefinedStep 3: Error Diagnosis and Auto-Fix
步骤3:错误诊断与自动修复
If compilation fails, read and fix common errors:
compile.logMissing packages:
! LaTeX Error: File `somepackage.sty' not found.→ Install via or remove the if unused.
tlmgr install somepackage\usepackageUndefined references:
LaTeX Warning: Reference `fig:xyz' on page 3 undefined→ Check exists in the correct figure environment.
\label{fig:xyz}Missing figures:
! LaTeX Error: File `figures/fig1.pdf' not found.→ Check if the file exists with a different extension (.png vs .pdf). Update the path.
\includegraphicsCitation undefined:
LaTeX Warning: Citation `smith2024' undefined→ Add the missing entry to or fix the citation key.
references.bib[VERIFY][VERIFY]/paper-writeOverfull 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\crefname{assumption}{Assumption}{Assumptions}\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:
- Read the error message from
compile.log - Locate the source file and line number
- Apply the fix
- Recompile
for attempt in 1..MAX_COMPILE_ATTEMPTS:
compile()
if success:
break
parse_errors()
auto_fix()针对每个错误:
- 从中读取错误信息
compile.log - 定位源文件和行号
- 应用修复方案
- 重新编译
Step 5: Post-Compilation Checks
步骤5:编译后检查
After successful compilation, verify the output:
bash
undefined编译成功后,验证输出结果:
bash
undefinedCheck 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中无"[?]"(未定义文献引用——查看日志)
- [ ] 图片已渲染(无缺失图片占位符)
```bashCheck 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
undefinedgrep -c "Citation.*undefined" compile.log
undefinedStep 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 :
pdftotextbash
undefined关键检查:验证主体内容是否在MAX_PAGES限制内。
主体内容 = 首页到结论部分结束(不一定是第5节——可能是第6、7或8节,取决于结构)。参考文献和附录不计入。
使用进行精确检查:
pdftotextbash
undefinedExtract 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.texbash
undefined检查未引用的孤立章节文件:
main.texbash
undefinedFind 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 markers: search the PDF text for leftover markers
[VERIFY]
针对会议投稿,需额外检查:
- 匿名性:无作者姓名、机构或可暴露身份的自引
- 页数限制:主体内容在MAX_PAGES内(到结论结束)
- 字体嵌入:所有字体已嵌入PDF
bash
pdffonts main.pdf | grep -v "yes" # 应无输出(仅表头除外) - 无混入补充内容:附录明确位于之后
\newpage\appendix - 文件大小:合理(大多数会议<50MB,建议<10MB)
- 无标记:在PDF文本中搜索遗留的标记
[VERIFY]
Step 8: Output Summary
步骤8:输出总结
markdown
undefinedmarkdown
undefinedCompilation 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 to fix any content issues
/paper-write - Submit to [venue] via OpenReview / CMT / HotCRP
undefined- 视觉检查PDF
- 运行修复内容问题
/paper-write - 通过OpenReview / CMT / HotCRP提交至[会议]
undefinedKey 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
常见会议要求
| Venue | Style File | Citation | Page Limit (main body) | Submission |
|---|---|---|---|---|
| ICLR 2026 | | | 9 pages (to Conclusion end) | OpenReview |
| NeurIPS 2025 | | | 9 pages (to Conclusion end) | OpenReview |
| ICML 2025 | | | 8 pages (to Conclusion end) | OpenReview |
| 会议 | 样式文件 | 引用格式 | 主体内容页数限制 | 投稿平台 |
|---|---|---|---|---|
| ICLR 2026 | | | 9页(到结论结束) | OpenReview |
| NeurIPS 2025 | | | 9页(到结论结束) | OpenReview |
| ICML 2025 | | | 8页(到结论结束) | OpenReview |