用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/lix965996-art/MMM --skill comp-compile-zh命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | comp-compile-zh |
| description | 数学建模竞赛中文论文编译与合规检查。编译 PDF 并检查页数、匿名、格式等竞赛要求。Use when user says "编译竞赛论文", "compile competition paper". |
| argument-hint | ["paper-directory"] |
| allowed-tools | Bash(*), Read, Write, Edit, Grep, Glob |
Compile and validate: $ARGUMENTS
ENGINE = xelatex
MAX_COMPILE_ATTEMPTS = 3
PAPER_DIR = paper/
MAX_PAGES / COMPETITION — From Additional Parameters.
if ! which xelatex 2>/dev/null; then
echo "xelatex not found, attempting install..."
if which miktex 2>/dev/null; then
miktex packages install xetex ctex xecjk gbt7714 fontspec
miktex fndb refresh
elif which initexmf 2>/dev/null; then
initexmf --set-config-value=[MPM]AutoInstall=1
fi
fi
which xelatex && which bibtex && echo "ready" || echo "xelatex/bibtex not found"
fc-list :lang=zh | head -5
kpsewhich gbt7714.sty 2>/dev/null || echo "gbt7714.sty not found (will auto-install on first compile)"
if [ -f "_utils/compile_utils.sh" ]; then
bash _utils/compile_utils.sh paper/
elif [ -f "skills/shared-scripts/compile_utils.sh" ]; then
bash skills/shared-scripts/compile_utils.sh paper/
else
echo "compile_utils.sh not found, manual cleanup needed"
fi
The script auto-handles: special chars cleanup, table format fixes, includegraphics path correction (figures/ → ../figures/), hidelinks, figures/figures/ nesting, math_commands conflicts, wide table resizebox wrapping, narrow table resizebox removal, light-color text fixes, TikZ library injection.
If script not found, perform these steps manually.
Also check ref/label matching and embed missing figures:
mkdir -p _tmp
grep -oh '\\ref{[^}]*}' paper/sections/*.tex paper/main.tex 2>/dev/null | sort -u > _tmp/_refs.txt
grep -oh '\\label{[^}]*}' paper/sections/*.tex paper/main.tex 2>/dev/null | sort -u > _tmp/_labels.txt
comm -23 <(sed 's/\\ref/\\label/g' _tmp/_refs.txt) _tmp/_labels.txt > _tmp/_missing_labels.txt
cat _tmp/_missing_labels.txt
If labels are missing, find corresponding figure/table code in figures/*.tex and embed into the correct section file.
Also check compile_utils.sh output for "UNEMBEDDED" warnings — each one means a figure or table from figures/ is not in any section.
MANDATORY FIX LOOP — do NOT proceed to compilation until all figures AND tables are embedded:
UNEMBED=0
# Check PDF figures
for pdf in figures/*.pdf; do
[ -f "$pdf" ] || continue
bn=$(basename "$pdf")
grep -rq "$bn" paper/sections/*.tex paper/main.tex 2>/dev/null || { echo "UNEMBEDDED PDF: $bn"; UNEMBED=$((UNEMBED+1)); }
done
# Check TABLE_*.tex files
for tbl in figures/TABLE_*.tex; do
[ -f "$tbl" ] || continue
bn=$(basename "$tbl")
# Check if any label from this table file appears in sections
for lbl in $(grep -oh '\\label{[^}]*}' "$tbl" 2>/dev/null); do
grep -rq "$lbl" paper/sections/*.tex paper/main.tex 2>/dev/null || { echo "UNEMBEDDED TABLE: $lbl (from $bn)"; UNEMBED=$((UNEMBED+1)); }
done
done
# Check latex_includes.tex labels
if [ -f figures/latex_includes.tex ]; then
for lbl in $(grep -oh '\\label{[^}]*}' figures/latex_includes.tex 2>/dev/null);
grep -rq paper/sections/*.tex paper/main.tex 2>/dev/null || { ; UNEMBED=$((UNEMBED+)); }
If UNEMBED > 0, you MUST fix ALL of them before compiling. For each unembedded item:
PDF figure: copy the \begin{figure}...\end{figure} block from figures/latex_includes.tex into the target section
TABLE_*.tex: copy the \begin{table}...\end{table} block from figures/TABLE_*.tex into the target section (use \input{../figures/TABLE_xxx.tex} or paste the tabular code directly)
Add 1-2 sentences of lead-in text before and 3-5 sentences of analysis after each embedded item
Re-run the count check above — repeat until UNEMBED = 0
Do NOT compile with unembedded figures or tables — the PDF will have missing content.
# Check all figures/*.pdf are referenced in body
for pdf in figures/*.pdf; do
[ -f "$pdf" ] || continue
bn=$(basename "$pdf")
grep -rq "$bn" paper/sections/*.tex paper/main.tex 2>/dev/null || echo "⚠ $bn not referenced"
done
cd paper/
xelatex -interaction=nonstopmode main.tex
bibtex main
xelatex -interaction=nonstopmode main.tex
xelatex -interaction=nonstopmode main.tex
After each compilation, check main.log for CRITICAL errors. You MUST fix ALL errors before declaring compilation complete.
# Count critical errors
MATH_ERR=$(grep -c 'Bad math environment delimiter\|Missing \$ inserted\|begin{document} ended by' paper/main.log 2>/dev/null || echo 0)
LR_ERR=$(grep -c 'Not allowed in LR mode' paper/main.log 2>/dev/null || echo 0)
UNDEF_CS=$(grep -c 'Undefined control sequence' paper/main.log 2>/dev/null || echo 0)
TOTAL_ERR=$((MATH_ERR + LR_ERR))
echo "Math errors: $MATH_ERR, LR mode errors: $LR_ERR, Undefined CS: $UNDEF_CS"
if [ "$TOTAL_ERR" -gt 0 ]; then
echo "CRITICAL: $TOTAL_ERR errors — MUST FIX before proceeding"
# Show error locations
grep -B2 'Bad math\|Missing \$ inserted\|begin{document} ended\|Not allowed in LR mode' paper/main.log | grep -E '^\./|^l\.' | head -20
fi
Error fix rules (iterate up to 5 times, not 3):
Math environment errors (Bad math environment delimiter, Missing $ inserted, \begin{document} ended by \end{equation}):
Read the error location from main.log (e.g., ./sections/3_model_theory.tex:42)
Open the file and find the broken math: usually \X(t)$ should be $X(t)$, or \mu$ should be $\mu$
Common cause: a sed/cleanup script stripped the opening $ but left the closing $
Fix: ensure every math expression has matching $...$ or \[...\] delimiters
Do NOT use broad sed patterns to fix math — read each error location and fix individually
LR mode errors (Not allowed in LR mode):
Usually caused by \begin{figure} or \begin{table} inside a paragraph without proper separation
Fix: add \par or blank line before the float environment
Undefined control sequence:
Missing package → add \usepackage{xxx} to main.tex preamble
Typo in command → fix the command name
BibTeX failures:
If BibTeX fails because of earlier LaTeX errors, fix the LaTeX errors first, then recompile
Check that \bibliography{references} and \bibliographystyle{plainnat} exist in main.tex
Check that references.bib has no syntax errors (unmatched braces, missing commas)
After each fix, recompile and recheck:
cd paper/
xelatex -interaction=nonstopmode main.tex
bibtex main 2>&1 | tail -5
xelatex -interaction=nonstopmode main.tex
xelatex -interaction=nonstopmode main.tex
cd ..
# Recheck
MATH_ERR=$(grep -c 'Bad math environment delimiter\|Missing \$ inserted' paper/main.log 2>/dev/null || echo 0)
echo "Remaining math errors: $MATH_ERR"
⛔ Do NOT proceed to Step 5 until MATH_ERR = 0 and LR_ERR = 0. BibTeX will also fail if there are LaTeX errors upstream — fix LaTeX first.
When fixing errors in main.tex, only fix the specific error (e.g., add a missing package, fix a typo). Do not rewrite or restructure main.tex — the template's preamble, cover page, page margins, section numbering format, and header/footer settings must remain unchanged.
bash _utils/compile_check.sh paper/ 2>/dev/null || bash skills/shared-scripts/compile_check.sh paper/
The script checks: PDF existence/size, undefined references, overfull hbox, TOC, abstracts, bibliography entries, citation count, unused figures, figure stacking, TikZ diagram presence.
Additionally check:
# List of figures / list of tables (stats competition requirement)
[ -s paper/main.lof ] && echo "✅ 插图清单已生成" || echo "⚠ 插图清单为空"
[ -s paper/main.lot ] && echo "✅ 表格清单已生成" || echo "⚠ 表格清单为空"
Template format verification (stats competition):
echo "=== 模板格式验证 ==="
if grep -q 'stats\|统计建模' paper/main.tex 2>/dev/null || [ "$COMPETITION" = "stats" ]; then
# Check page margins (should be 2.54cm top/bottom, 3.17cm left/right)
grep -q '2.54cm' paper/main.tex && echo "✅ 页边距正确" || echo "⚠ 页边距可能不对(应为上下2.54cm,左右3.17cm)"
# Check Chinese section numbering
grep -q 'chinese{section}' paper/main.tex && echo "✅ 中文章节编号" || echo "⚠ 缺少中文章节编号(一、二、三...)"
# Check cover page
grep -q '参赛学校\|参赛作品\|作品编号' paper/main.tex && echo "✅ 封面存在" || echo "⚠ 缺少封面"
# Check abstract format (should be \section*{摘要}, not \begin{abstract})
grep -q 'section\*.*摘要' paper/main.tex && echo "✅ 摘要格式正确" || echo "⚠ 摘要格式可能不对"
# Check natbib (stats uses natbib, not gbt7714)
grep -q 'natbib' paper/main.tex && echo "✅ natbib 引用格式" || echo "⚠ 缺少 natbib(统计建模应用 natbib)"
# Check no header line
grep -q 'headrulewidth.*0pt' paper/main.tex && echo "✅ 无页眉线" || echo "⚠ 可能有页眉线"
# Check listoffigures / listoftables
grep -q paper/main.tex && ||
grep -q paper/main.tex && ||
If any format checks fail, Claude should fix main.tex to match the template format before recompiling.
Check items:
Page count: body = chapter 1 through conclusion, excluding 摘要/目录/参考文献/附录. Must be ≥ MAX_PAGES (can exceed, must not fall short)
Anonymous: no team info (队号, 队员, 指导老师)
Abstract exists (数模竞赛: at least Chinese; 统计建模: both Chinese and English)
TOC exists (required by MathorCup etc.)
Code appendix exists
No undefined references/citations
<page_diagnosis>
If body pages < 80% of MAX_PAGES:
echo "=== 页数不足诊断 ==="
echo "目标: ≥ MAX_PAGES 页"
echo ""
echo "=== 各章节字符数(找出最薄的章节)==="
for f in paper/sections/*.tex; do
chars=$(wc -c < "$f")
echo " $(basename $f): $chars 字符 (~$(echo "scale=1; $chars/900" | bc) 页)"
done
echo ""
echo "=== 建议扩充的章节(字符数最少的 3 个)==="
for f in $(ls -S paper/sections/*.tex | tail -3); do
chars=$(wc -c < "$f")
echo " ⚠ $(basename $f): 仅 $chars 字符"
done
Mark as CRITICAL with specific recommendations:
Which chapters are thinnest
What content to add (more derivation? more result analysis? more literature discussion?)
Estimated chars needed to reach target
If pages < 80% of MAX_PAGES, attempt to expand the thinnest 1-2 chapters:
Read MODELING_REPORT.md and RESULTS.md for detailed content
Add unexpanded derivations, result analysis, parameter discussions
Recompile after expansion
</page_diagnosis>
Run all checks and verify every item passes. Do NOT output the report until all CRITICAL items are resolved.
echo "=========================================="
echo " FINAL QUALITY GATE"
echo "=========================================="
GATE_FAIL=0
# 1. PDF exists and non-trivial
if [ -f paper/main.pdf ] && [ $(wc -c < paper/main.pdf) -gt 100000 ]; then
echo "✅ PDF exists ($(wc -c < paper/main.pdf) bytes)"
else
echo "❌ PDF missing or too small"; GATE_FAIL=$((GATE_FAIL+1))
fi
# 2. No LaTeX errors
MATH_ERR=$(grep -c 'Bad math environment delimiter\|Missing \$ inserted' paper/main.log 2>/dev/null || echo 0)
LR_ERR=$(grep -c 'Not allowed in LR mode' paper/main.log 2>/dev/null || echo 0)
[ "$((MATH_ERR+LR_ERR))" -eq 0 ] && echo "✅ No LaTeX errors" || { echo "❌ $MATH_ERR math + $LR_ERR LR errors"; GATE_FAIL=$((GATE_FAIL+1)); }
# 3. Bibliography not empty
BBL_ENTRIES=$(grep -c '\\bibitem' paper/main.bbl 2>/dev/null || echo 0)
[ "$BBL_ENTRIES" -gt 0 ] && echo "✅ Bibliography: $BBL_ENTRIES entries" || { echo "❌ Bibliography empty (BibTeX failed)"; GATE_FAIL=$((GATE_FAIL+1)); }
# 4. No unembedded figures
UNEMBED=0
pdf figures/*.pdf;
[ -f ] ||
bn=$( )
grep -rq paper/sections/*.tex paper/main.tex 2>/dev/null || UNEMBED=$((UNEMBED+))
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
PAGE_EST=0
f paper/sections/*.tex; [ -f ] || ; c=$( -c < ); PAGE_EST=$((PAGE_EST + c));
PAGE_EST=$((PAGE_EST / ))
VBOX_ERR=$(grep -c paper/main.log 2>/dev/null || 0)
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
AI_LISTS=0
f paper/sections/*.tex;
[ -f ] ||
| grep -qi &&
c=$(grep -c 2>/dev/null || 0)
AI_LISTS=$((AI_LISTS + c))
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
TMPL=
t _templates/stats_main.tex _templates/cumcm_main.tex _templates/mcm_main.tex _templates/bachelor_main.tex _templates/master_main.tex _templates/journal_main.tex;
[ -f ] && TMPL= &&
[ -n ] && [ -f paper/main.tex ];
TMPL_PRE=$(sed -n | grep | )
MAIN_PRE=$(sed -n paper/main.tex | grep | )
MISSING=$( -23 <( ) <( ) 2>/dev/null | -5)
[ -z ];
| sed
GATE_FAIL=$((GATE_FAIL+))
grep -q 2>/dev/null;
grep -q paper/main.tex 2>/dev/null && || { ; GATE_FAIL=$((GATE_FAIL+)); }
grep -q paper/main.tex 2>/dev/null && || { ; GATE_FAIL=$((GATE_FAIL+)); }
grep -q paper/main.tex 2>/dev/null;
; GATE_FAIL=$((GATE_FAIL+))
grep -P paper/main.tex 2>/dev/null | -1 | grep -q ;
; GATE_FAIL=$((GATE_FAIL+))
PLAN_FIGS=0; ACTUAL_FIGS=$( figures/*.pdf 2>/dev/null | -l)
plan TOPIC_PLAN.md PAPER_PLAN.md PROBLEM_ANALYSIS.md;
[ -f ] ||
pf=$(grep -ci 2>/dev/null || 0)
[ -gt ] && PLAN_FIGS=
[ -gt 0 ];
[ -ge ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
TIKZ_IN_PAPER=$(grep -rl paper/sections/*.tex 2>/dev/null | -l)
[ -gt 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
CITE_COUNT=$(grep -roh paper/sections/*.tex paper/main.tex 2>/dev/null | -l)
[ -gt 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
PLACEHOLDERS=$(grep -rl paper/sections/*.tex paper/main.tex 2>/dev/null | -l)
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
UNDEF_REFS=$(grep -c paper/main.log 2>/dev/null || 0)
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
HBOX_ERR=$(grep -c paper/main.log 2>/dev/null || 0)
[ -lt 5 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
STACKING=0
f paper/sections/*.tex; [ -f ] || ; s=$(awk 2>/dev/null); STACKING=$((STACKING+s));
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
grep -q paper/main.tex 2>/dev/null;
[ -s paper/main.toc ] && || {
paper/
xelatex -interaction=nonstopmode main.tex > /dev/null 2>&1
xelatex -interaction=nonstopmode main.tex > /dev/null 2>&1
..
[ -s paper/main.toc ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
}
grep -q paper/main.tex 2>/dev/null;
grep -rq paper/sections/*.tex paper/main.tex 2>/dev/null && || { ; GATE_FAIL=$((GATE_FAIL+)); }
grep -rq paper/sections/*.tex paper/main.tex 2>/dev/null && || { ; GATE_FAIL=$((GATE_FAIL+)); }
bash _utils/compile_check.sh paper/ 2>/dev/null || bash skills/shared-scripts/compile_check.sh paper/ 2>/dev/null
bash _utils/writing_check.sh paper/ 2>/dev/null || bash skills/shared-scripts/writing_check.sh paper/ 2>/dev/null
WC_EXIT=$?
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
f paper/sections/*.tex;
[ -f ] ||
grep -q 2>/dev/null;
grep -q 2>/dev/null;
grep -q 2>/dev/null;
; GATE_FAIL=$((GATE_FAIL+))
f paper/sections/*.tex;
[ -f ] ||
| grep -qi &&
grep -q 2>/dev/null;
ROW_COUNT=$(awk 2>/dev/null | grep -c || 0)
[ -gt 15 ] && { ; GATE_FAIL=$((GATE_FAIL+)); }
grep -q paper/main.tex 2>/dev/null;
grep -q paper/main.tex 2>/dev/null && { ; GATE_FAIL=$((GATE_FAIL+)); } ||
[ -f figures/all_results.json ];
python3 -c 2>/dev/null
[ $? -ne 0 ] && GATE_FAIL=$((GATE_FAIL+))
[ -f figures/all_results.json ];
python3 -c 2>/dev/null
[ -f RESULTS.md ];
grep -q RESULTS.md 2>/dev/null;
GATE_FAIL=$((GATE_FAIL+))
[ -f figures/all_results.json ];
JSON_TIME=$( -c %Y figures/all_results.json 2>/dev/null || -f %m figures/all_results.json 2>/dev/null || 0)
STALE_FIGS=0
pdf figures/*.pdf;
[ -f ] ||
PDF_TIME=$( -c %Y 2>/dev/null || -f %m 2>/dev/null || 0)
[ -gt ] && [ -gt 60 ];
STALE_FIGS=$((STALE_FIGS+))
[ -gt 0 ];
GATE_FAIL=$((GATE_FAIL+))
LONG_TABLES=0
f paper/sections/*.tex;
[ -f ] ||
| grep -qi &&
python3 -c 2>/dev/null | line;
LONG_TABLES=$((LONG_TABLES+))
[ -eq 0 ] && || GATE_FAIL=$((GATE_FAIL+))
AI_LISTS=0
f paper/sections/*.tex;
[ -f ] ||
| grep -qi &&
c=$(grep -c 2>/dev/null || 0)
AI_LISTS=$((AI_LISTS+c))
[ -le 3 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
META=0
f paper/sections/*.tex;
[ -f ] ||
l=$(grep -ci 2>/dev/null || 0)
META=$((META+l))
[ -eq 0 ] && || { ; GATE_FAIL=$((GATE_FAIL+)); }
OC=0
f paper/sections/*.tex;
[ -f ] ||
w ;
c=$(grep -c 2>/dev/null || 0); OC=$((OC+c))
[ -eq 0 ] && ||
[ -eq 0 ];
⛔ If GATE_FAIL > 0, you MUST go back and fix every ❌ item, recompile, and re-run this gate. Do NOT output the final report with any ❌ remaining. Repeat until GATE_FAIL = 0.
Competition name, status, PDF path, total pages, body pages, compliance pass/fail.
No latexmk — manual step-by-step compilation
Do not delete .bbl file after compilation (bibliography data)
Figure paths auto-corrected by compile_utils.sh: figures/ → ../figures/
Body pages ≥ MAX_PAGES (can exceed, must not fall short)
Anonymous: no team info in body
Primary output: paper/main.pdf, temp files: _tmp/