This skill is the final gate of the complete workflow. It does not re-model, does not generate new results, and does not rewrite the paper in place of the writing stage; it is responsible for finding hard errors, fixing issues that can be fixed directly, and outputting reports/VERIFY_REPORT.md。
Mathematical Modeling Standards Reference
If domain judgment is needed, read the "Paper Acceptance and Consistency" subsection in ../_references/math_modeling_norms.md . That file is only a standards knowledge base, not a fixed execution process; the specific directories, entry files, result files, and figure and table directories are determined by the current project structure.
Stage Boundaries
- This stage is responsible for: structural acceptance, text quality gates, figure and table reference checks, result consistency checks, Typst/LaTeX compilation checks, PDF visual checks, and the submission checklist.
- This stage is not responsible for: redesigning the model, re-running large-scale experiments, or reorganizing the entire paper.
- When hard errors are found, prioritize small-scope fixes; if it is necessary to return to a previous stage, write to
reports/VERIFY_REPORT.mdand mark it as failed.
Inputs
The model should first determine the project layout based on the current workspace, and then pass the actual paths to the check script. Common inputs include but are not limited to:
- Paper entry file:
main.typ(Typst) ormain.tex(LaTeX)。 - Main body section directory or several main body files (
.typor.tex)。 - Bibliography file (
references.typorreferences.tex)。 - Analysis, modeling, results, and figure reports from previous stages.
- Figure and table directories
- Reproducible code directory.
- The compiled PDF, or the output PDF that can be obtained by compiling the entry file.
Do not assume that the paper directory must be named paper/, and do not assume that result files must be in the project root. If the project uses different naming, pass parameters according to the actual structure and explain in reports/VERIFY_REPORT.md .
Workflow
Step 1: Run the text quality gate
Prioritize running this skill's script. The script automatically selects the check logic according to the entry file extension (.typ → Typst check,.tex → LaTeX check):
set -o pipefail
mkdir -p _tmp
SCRIPT_PATH="<按当前 skill 实际位置确定>/scripts/writing_check.sh"
bash "$SCRIPT_PATH" \
--paper-dir "$PAPER_DIR" \
--main "$MAIN_FILE" \
--sections-dir "$SECTIONS_DIR" \
--references "$REFERENCES_FILE" \
--figures-dir "$FIGURES_DIR" \
--results-file "$RESULTS_FILE" \
--problem-analysis "$PROBLEM_ANALYSIS_FILE" \
--all-results "$ALL_RESULTS_FILE" \
| tee _tmp/writing_check.log
If this skill is copied to another directory, use the actual script path. You can first run bash <script> --help to view the parameters. Do not hard-code the script path, paper directory, or file names into the acceptance logic.
The script only scans text; it does not generate the paper, nor does it compile the PDF. Its FAIL are hard errors and must be fixed before rerunning.
Step 2: Number of sections and heading order
Typst EngineCheck:
- Entry
.typfile's#include("...")count matches the actual main body structure. - Whether the include order matches the file name prefix order, for example
1_...,2_...,3_...。 - Whether each section has a clear level-one heading (
= 标题, with a space after the equals sign). - Whether the heading order matches the selected paper type.
LaTeX EngineCheck:
- Entry
.texfile's\input{...}or\include{...}count matches the actual main body structure. - Whether the section order matches the order of the filename prefixes.
- Whether each section has
\section{}or a heading at the corresponding level.
General checks (both engines):
- Whether section files are missing, referenced multiple times, or never referenced.
- If the problem is not a three-part question, do not force three problem sections; check against the number of subproblems in
ANALYSIS_MODELING_REPORT.md.
Step 3: Figure and section matching
Typst engineCheck:
- Whether the PDFs in the figure directory are referenced in the main text.
#figure(image(...), caption: [...])Whether the images in.typactually exist. Image paths must be relative to the- Whether data figures are placed in the corresponding results/analysis section, and non-data flowcharts are placed in the methods/overall approach section.
LaTeX engineCheck:
\includegraphics{}Whether the image files referenced by.texactually exist. Paths are relative to the\caption{}exists.- Whether data figures are placed in the corresponding results/analysis section.
General checks (both engines):
- Whether there is enough explanatory text between consecutive figures.
- Whether captions are too long, too generic, or inconsistent with the meaning of the figure.
- Whether figure numbering, main-text references, and section semantics are consistent.
Do not generate *_typst_includes.typ or *_latex_includes.tex; figures must be embedded directly in the corresponding section.
Step 4: Writing quality and leakage checks
Check and fix:
TODO、PLACEHOLDER、待补充、待续写、示例数据and other placeholders.- The main body of the paper contains internal workflow filenames, temporary directory names, code directory names, or result JSON paths.
- Excessive list-style writing (a large number of
#list、enumin Typst, a large number of\begin{itemize}、\begin{enumerate})。 - Paragraphs repeatedly begin with "as shown in Figure", "from Figure", or "Figure X shows".
- No explanation after figures, no meaning of variables after formulas, and conclusions that only report numbers without explanation.
Step 5: Numerical and result consistency
Check:
- Key numerical values in the paper must come from the result records or result JSON declared by the current workflow.
- Objective function values, error metrics, rankings, weights, thresholds, and sensitivity results must not conflict with the result records.
- If a summary result JSON exists, extract key metrics and confirm that the main body of the paper has corresponding results.
- Symbols in formulas should be explained in the symbol description or where they first appear in the main text.
When numerical conflicts are found, do not invent new results on your own; return to the result records or code output to correct the paper.
Step 6: Citations and template specifications
Check:
- Whether the bibliography file exists, or whether the template uses another real bibliography mechanism.
- Whether main-text citation markers (Typst's
@label/#super, LaTeX's\cite{}) can be matched to real references. - Captions, table titles, and abstract language in Chinese papers remain in Chinese; English papers remain in English.
- Whether the selected template entry point retains the necessary cover page, abstract, numbering, headers and footers, or submission format of the selected competition template.
- Do not mistakenly delete the template structure into an ordinary blank document.
Step 7: Compilation
Typst compilation:
command -v typst >/dev/null 2>&1 && typst compile "$MAIN_FILE" "$OUTPUT_PDF"
LaTeX compilation:
command -v xelatex >/dev/null 2>&1 && xelatex -interaction=nonstopmode "$MAIN_FILE" && xelatex -interaction=nonstopmode "$MAIN_FILE"
xelatex needs to be run twice to resolve the table of contents and cross-references.
After a compilation failure, you must fix syntax, path, image reference, or template issues and rerun. After compilation passes, confirm that the output PDF is non-empty.
Step 8: PDF visual inspection
If the model has visual capabilities, it must export each page of the compiled PDF as PNG and inspect them page by page. This step is used to find layout errors that plain text scanning and the compiler cannot detect.
Prefer using tools already available in the system to export page PNGs; do not introduce heavy dependencies just for visual inspection. Optional command example:
mkdir -p _tmp/pdf-pages
if command -v pdftoppm >/dev/null 2>&1; then
pdftoppm -png -r 160 "$OUTPUT_PDF" _tmp/pdf-pages/page
elif command -v mutool >/dev/null 2>&1; then
mutool draw -r 160 -o _tmp/pdf-pages/page-%03d.png "$OUTPUT_PDF"
elif command -v magick >/dev/null 2>&1; then
magick -density 160 "$OUTPUT_PDF" _tmp/pdf-pages/page-%03d.png
else
echo "No PDF rasterizer found; record visual check as not run."
fi
After export, check page by page:
- Whether pages are blank, missing, have an abnormal page count, or have abnormal page sizes.
- Whether the title, abstract, main text, headers and footers, and page numbers are clipped or obviously incorrectly positioned.
- Whether tables exceed the page margins, and whether cell text overlaps, overflows, or is truncated.
- Whether images, figure captions, table captions, formulas, and numbering overlap with the main text.
- Whether formulas exceed the boundaries, and whether long formulas press into the page margins or the next paragraph of text.
- Whether lists, paragraphs, footnotes, and references have abnormally large blank spaces, overlaps, or orphaned lines.
- Whether Chinese/English/mathematical symbol fonts have obvious missing glyphs, garbled characters, or abnormal fallback.
- Whether key template pages such as the cover, abstract page, table of contents, and appendix retain the visual structure required by the competition.
If it is a template conversion or a project with an existing reference PDF, you should also export the PDFs from different engines as PNGs page by page and compare layout differences page by page; inconsistent page counts or page sizes must be recorded as hard errors or the reason must be clearly explained.
If the model has no visual capabilities, it must clearly state the reason for "visual inspection not performed" in reports/VERIFY_REPORT.md , and at least complete programmatically checkable checks such as PDF non-emptiness, page count, and page size.
Step 9: Write the acceptance report
Create reports/VERIFY_REPORT.md:
# 验证和验收报告
## 结论
PASS / FAIL
## 检查项
| 检查项 | 结果 | 说明 |
| --- | --- | --- |
## 章节结构
## 图表引用
## 数值一致性
## 文本质量门禁
## 编译
## PDF 视觉检查
## 仍需处理的问题
Only when all hard errors have been fixed, the text gate passes, all core figures and tables are referenced, numerical values are consistent, compilation passes or the reason why compilation is impossible is clearly explained, and visual inspection passes or the reason why it cannot be performed is clearly explained, write PASS。
Hard error criteria
The following problems must be judged as FAIL:
- Missing the selected paper entry file (
main.typormain.tex) or the core main text. - A chapter file referenced by the paper entry does not exist.
- The Typst entry is missing
#include; the LaTeX entry is missing\input/\include。 - A main text chapter is missing a first-level heading (missing space after Typst
=, missing LaTeX\section{}). - The chapter order is obviously wrong or duplicated.
- The main text still contains placeholders.
- The main text leaks internal workflow file names.
- A referenced image does not exist.
- Key numerical values conflict with the result records.
- The compiler is available but the paper fails to compile.
- The compiled PDF is empty, missing pages, has an abnormal page count, or has an abnormal page size and cannot be explained.
- Visual inspection finds that key elements such as the main text, tables, images, formulas, headers and footers, and page numbers overlap, are clipped, exceed boundaries, or are garbled.
Warning criteria
The following problems may be judged as WARN, but should be fixed as much as possible:
- Unreferenced backup images.
- A chapter is too short or obviously unbalanced.
- A caption is too long.
- Too few references.
- Insufficient explanatory text after figures and tables.
- The visual inspection tool is unavailable, but the reason has been recorded and the basic PDF metadata check has been completed.
- A full code reproduction would take too long, so only a lightweight check was performed.