Legal Homework Formatter
Purpose
This skill provides standardized formatting workflows for Chinese legal homework assignments. It helps documents follow a user-provided course template and the Law Journal Citation Handbook, while resolving common compatibility issues between WPS and Microsoft Word.
When to Use
Use this skill when:
- Creating new Chinese legal homework assignments in Word format
- Formatting existing homework to meet citation standards
- Fixing footnote display issues between WPS and Word
- Adjusting title, heading, or citation formats
- Generating or repairing a homework table of contents (目录/TOC)
- Converting draft content to properly formatted legal documents
Privacy and Required Inputs
This public version must never default to the maintainer's personal information or a private course template.
Before generating a title, filename, header, or metadata, ask the user for:
- assignment date/course prefix, only if the current instructions require one;
- assignment number/title;
- student name;
- student ID, if required;
- course or instructor-specific template, if required.
If the user does not provide a required identity field, use an explicit placeholder such as [待补: 姓名] or [待补: 学号] and flag it in the final checklist. Do not infer, reuse, or hard-code a real person's name, ID, school, email address, or local file path.
Reference Template
Use the user-provided course reference template as the base for generating homework documents when one is available. Its style system is the authoritative source for course-specific formatting. If no template is provided, create a conservative .docx with the formatting rules below and clearly tell the user which template-dependent checks could not be performed.
This public skill also includes an anonymized fallback template at:
textassets/legal-homework-template-anonymized.docx
Use it when the user needs a working Word style base but has not provided a private course template. The template keeps the formatting structure while replacing identity fields with [日期], [序号], [姓名], and [学号]. Do not rename it to a private course filename when publishing or redistributing the skill.
For a user-facing material checklist and missing-information workflow, read:
textreferences/user_materials_guide.md
Lessons From the 2026-05-13 Homework Formatting Pass
When the user asks to "strictly follow the homework skill" or provides the course reference template/PPT, apply these verified rules rather than relying on generic python-docx defaults:
- Use the user-provided reference template as the ZIP/DOCX base when available, not a blank document.
- Match the course PPT's "三名同一" rule: email subject, attachment file name, and document title should be identical.
- Derive the title pattern from the current assignment or instructor instructions. Do not carry a date prefix or
graded homework Nwording from an older course merely because it appears in a reused template. If the user supplies the intended filename, use its basename as the document title unless the current assignment requires a different title. - Main title: 小三, centered, no first-line indent,
spacing after="156", split the title into runs so Chinese name and hyphens render in 宋体 while English/date/student ID render in Times New Roman. - Body paragraphs: 五号, 宋体/Times New Roman, first-line indent
420twips, line spacing300(1.25x), paragraph after156twips, justified alignment. - Paragraph-after unit check:
w:after="156"is stored in OOXML twips, equal to 7.8 pt because Word uses twentieths of a point. In the civil-law reference template this corresponds to half of the document grid line pitch (docGrid linePitch="312"), so Word/WPS may display the same setting as about0.5 行or7.8 磅depending on UI/context. Treat these as equivalent, not conflicting. - Footnotes: 小五, 宋体/Times New Roman, single line spacing, left aligned, no first-line indent, no paragraph spacing before/after.
- Footnote numbering: remove
<w:numRestart w:val="eachPage"/>fromword/settings.xmland any section-levelfootnotePr; homework footnotes should number continuously across the whole document. The reference template containseachPage, but that setting causes duplicate-looking footnote numbers page by page. - If a heading already contains a manual Chinese prefix such as
一、or(一), suppress any inherited automatic numbering on that confirmed paragraph (for example, direct<w:numPr><w:numId w:val="0"/></w:numPr>). Preserve its existing paragraph style. Do not globally rewrite styles1/2/3merely by numeric ID: WPS may renumber style IDs, and the same style may still be needed by genuinely auto-numbered paragraphs. - If the document was generated from Markdown/Pandoc or any converter that applies Word
Heading1/Heading2styles, do not only override run fonts and sizes. Also remove inherited heading paragraph styles and decorations from the final document, or Word may still render blue/green heading colors and automatic bullets/numbering:- remove
<w:pStyle w:val="Heading1"/>,<w:pStyle w:val="Heading2"/>, and similar converted heading styles from manually numbered titles/headings; - during artifact cleanup, remove converter-generated direct
<w:numPr>from titles/headings. After assigning the final course style/outline, a confirmed manually numbered heading must end with directw:numId=0if its retained style inherits automatic numbering; cleanup is not the final numbering state; - clear run-level
<w:color>values inherited from styles/themes, especiallyw:themeColor, then set direct black color<w:color w:val="000000"/>; - remove
<w:highlight>and<w:shd>on generated title/heading runs unless the user explicitly asks for color. - run
python3 scripts/fix_pandoc_heading_artifacts.py input.docx --output output.docxbefore the final compatibility check when the source DOCX came from Pandoc/Markdown. This bug appeared in a 2026-05-27 Word check: Pandoc's heading style survived OOXML post-processing, so Word displayed the main title and headings in blue-green and with black bullet markers even though font/size had been overwritten.
- remove
- After running any quote normalizer, re-check footnotes: standalone curly quote runs in footnotes may accidentally inherit body size. Force footnote quote runs (
“”‘’) back to 小五 (w:sz=18) and 宋体. - Do not save a finished footnoted document with
python-docxafter manually editing footnotes unless you have verifiedword/footnotes.xmlandfootnoteReferencemarkers are preserved. Prefer ZIP/XML surgery for final footnote and quote fixes. - Before writing footnote text into DOCX, strip leading/trailing whitespace from the citation payload. The template may use one normal delimiter space after the footnote number, but the citation text itself must not start with an extra blank.
- Do not place two footnote references back-to-back after the same sentence-final punctuation. If multiple sources support the same claim, combine them in one footnote separated by
;; if they support different clauses, place each marker after its own clause or legal article. - The homework template may include Chinese TOC styles. To add a directory, use the template's TOC styles and a clean Word field, but do not copy dirty old preview entries such as
PAGEREF _Toc.... - For Word compatibility, do not set
<w:updateFields w:val="true"/>just to force TOC updates. Word will show a field-update prompt. Also avoid copying a template's wholew:sdtTOC content-control shell into generated files unless you have verified Word opens without repair prompts. Prefer clean ordinary TOC field paragraphs plus static preview entries. - Preserve WordprocessingML child order in generated paragraph properties. Word may show "unreadable content" even when ZIP/XML parsing succeeds if, for example,
w:spacingappears beforew:tabsin a TOC entry orw:pageBreakBeforeis inserted beforew:pStyle. - Homework TOC layout: the document title and
目录stay on the first page; the main body starts on the next page by settingw:pageBreakBeforeon the first body paragraph, not by inserting a visible<w:br w:type="page"/>. - Heading detection for TOC must use both style and text structure. Existing styles
1/2/3are strong clues but not always trustworthy because users often hand-format titles. Confirm with text patterns like一、,(一), and1.before including a paragraph in the TOC.
Style System (OOXML Reference)
Based on the reference template's styles.xml:
Paragraph Styles
| styleId | Name | sz (半磅) | 对应中文 | Bold | Other |
|---|---|---|---|---|---|
a | Normal | 21 (五号/10.5pt) | 正文 | No | line=300 (1.25倍), after=50, firstLine=200, widowControl=0, adjustRightInd=0, snapToGrid=0 |
1 | heading 1 | 28 (四号/14pt) | 一级标题 | Yes | keepNext, keepLines, numPr (auto "一、") |
2 | heading 2 | 24 (小四号/12pt) | 二级标题 | Yes | keepNext, keepLines, numPr (auto "(一)") |
3 | heading 3 | 21 (五号) | 三级标题 | Yes | keepNext, keepLines |
a7 | footnote text | 18 (小五号/9pt) | 脚注文本 | No | line=240 (单倍), left aligned |
TOC10 | TOC 标题1 | 28 (四号/14pt) | 目录标题 | No | centered, black |
TOC1 | toc 1 | 21/22-ish | 一级目录项 | No | right tab with dot leader when generated |
TOC2 | toc 2 | 21/22-ish | 二级目录项 | No | indented TOC item |
TOC3 | toc 3 | 21/22-ish | 三级目录项 | No | further indented TOC item |
Character Styles
| styleId | Name | Purpose |
|---|---|---|
ab | footnote reference | Superscript footnote markers (上标) |
docDefaults
sz=21(五号/10.5pt),szCs=22(default paragraph-level rPr)- Default fonts in docDefaults:
ascii="Times New Roman" eastAsia="宋体" hAnsi="Times New Roman" cs="Times New Roman" - These are explicit font names, NOT theme font references (minorHAnsi/minorEastAsia)
Document Generation Workflow
Step 1: Gather Required Materials
- Homework questions (PDF/DOCX) - assignment requirements
- Reference template - user-provided formatting base, if required by the course
- Student information and naming fields - ask for name (姓名), student ID (学号), and only the date/course prefix required by the current assignment; use
[待补: ...]placeholders if a required field is missing
Step 2: Build Document Using Reference Template
Use the reference template as the ZIP base. Key principles:
Heading paragraphs (一级标题 like "一、XXX"):
xml<w:p> <w:pPr><w:pStyle w:val="1"/><w:spacing w:after="156"/></w:pPr> <w:r><w:t xml:space="preserve">一、菜单案</w:t></w:r> </w:p>
- Use pStyle="1" for 一级标题, pStyle="2" for 二级标题
- Run does NOT need rPr — style provides sz=28/24 and bold
- IMPORTANT: For a paragraph whose visible text already includes manual numbering, suppress inherited numbering directly on that paragraph while preserving its style. Modify a whole heading style only when the template proves that every paragraph using it is manually numbered.
Body paragraphs (正文):
xml<w:p> <w:pPr><w:spacing w:line="300" w:lineRule="auto" w:after="156"/> <w:ind w:firstLine="420"/><w:jc w:val="both"/></w:pPr> <w:r><w:rPr><w:rFonts w:hint="eastAsia"/></w:rPr> <w:t xml:space="preserve">正文内容...</w:t> </w:r> </w:p>
- NO pStyle (inherits Normal/a: sz=21, line=300)
- Run rPr: only
<w:rFonts w:hint="eastAsia"/>— NO explicit sz - Bold body runs: add
<w:b/><w:bCs/>to rPr - First-line indent: 420 twips (≈2 chars)
- Paragraph after: use 156 twips for generated homework body paragraphs. Although Normal style may show
after=50, the course reference template's actual filled body paragraphs useafter=156, and this is the safer value for submitted homework. - Alignment: set
<w:jc w:val="both"/>explicitly to avoid Word/WPS drift.
Document title (split into multiple runs, hyphen in 宋体 font):
xml<w:p> <w:pPr> <w:spacing w:after="156"/> <w:ind w:firstLineChars="0" w:firstLine="0"/> <w:jc w:val="center"/> <w:rPr><w:sz w:val="30"/><w:szCs w:val="30"/></w:rPr> </w:pPr> <!-- 文字 run:hint eastAsia --> <w:r><w:rPr><w:rFonts w:hint="eastAsia"/><w:sz w:val="30"/> <w:szCs w:val="30"/><w:b/><w:bCs/></w:rPr> <w:t xml:space="preserve">当前作业要求的标题前缀</w:t></w:r> <!-- 连字符 run:显式 宋体 --> <w:r><w:rPr><w:rFonts w:ascii="宋体" w:hAnsi="宋体" w:cs="宋体" w:hint="eastAsia"/><w:sz w:val="30"/><w:szCs w:val="30"/> <w:b/><w:bCs/></w:rPr> <w:t xml:space="preserve">-</w:t></w:r> <!-- 姓名 run --> <w:r><w:rPr><w:rFonts w:hint="eastAsia"/><w:sz w:val="30"/> <w:szCs w:val="30"/><w:b/><w:bCs/></w:rPr> <w:t xml:space="preserve">[待补: 姓名]</w:t></w:r> <!-- 连字符 run --> <w:r><w:rPr><w:rFonts w:ascii="宋体" w:hAnsi="宋体" w:cs="宋体" w:hint="eastAsia"/><w:sz w:val="30"/><w:szCs w:val="30"/> <w:b/><w:bCs/></w:rPr> <w:t xml:space="preserve">-</w:t></w:r> <!-- 学号 run --> <w:r><w:rPr><w:rFonts w:hint="eastAsia"/><w:sz w:val="30"/> <w:szCs w:val="30"/><w:b/><w:bCs/></w:rPr> <w:t xml:space="preserve">[待补: 学号]</w:t></w:r> </w:p>
- NO pStyle, centered, sz=30 (小三号/15pt), bold
- A date prefix is conditional, not universal. If the current course requires one, ask whether it represents the release date, due date, or another value instead of guessing.
- IMPORTANT: Hyphen "-" must be in its own run with explicit 宋体 font (ascii/hAnsi/cs all set to "宋体")
- IMPORTANT: pPr must include
<w:ind w:firstLineChars="0" w:firstLine="0"/>and<w:rPr>block - Split the title into the runs needed by the current naming pattern. A prefix-name-ID pattern commonly uses five runs: prefix, hyphen, name, hyphen, student ID.
Footnote references (in body text):
xml<w:r> <w:rPr><w:rStyle w:val="ab"/></w:rPr> <w:footnoteReference w:id="4"/> </w:r>
- Use character style rStyle="ab" (superscript, 9pt)
- Each footnoteReference must have a UNIQUE ID
- The course reference template uses separator IDs
-1and0; its sample regular footnote uses ID1. - Starting newly generated footnotes at
4is a conservative compatibility strategy for programmatic generation/repair, not a template requirement. It avoids collisions with legacy or AI-generated documents that misuse low IDs for separators or ordinary notes. - If preserving an existing clean template footnote, do not renumber it merely because it is ID
1; only ensure everyfootnoteReferencehas a matchingfootnotedefinition.
Footnote definitions (in footnotes.xml):
xml<w:footnote w:id="4"> <w:p> <w:pPr> <w:pStyle w:val="a7"/> <w:spacing w:before="0" w:after="0" w:line="240" w:lineRule="auto"/> <w:ind w:left="0" w:right="0" w:firstLine="0"/> <w:jc w:val="left"/> </w:pPr> <w:r><w:rPr><w:rStyle w:val="ab"/></w:rPr><w:footnoteRef/></w:r> <w:r><w:t xml:space="preserve"> </w:t></w:r> <w:r><w:rPr><w:rFonts w:hint="eastAsia"/></w:rPr> <w:t xml:space="preserve">《民法典》第X条。</w:t> </w:r> </w:p> </w:footnote>
- Paragraph style: pStyle="a7" (sz=18/小五号, line=240/单倍)
- footnoteRef: rStyle="ab" (superscript)
- Text runs: only
<w:rFonts w:hint="eastAsia"/>, sz=18 from a7 style - Separator: w:id="-1" (separator), w:id="0" (continuationSeparator)
- If footnote text contains Chinese quotation marks, ensure the quote runs are also 小五:
<w:rFonts w:ascii="宋体" w:hAnsi="宋体" w:eastAsia="宋体"/>plus<w:sz w:val="18"/>. - Nested Chinese quotation marks should be outer double and inner single, e.g.
“违反‘打黑工’禁令的合同”.
Step 3: Heading Hierarchy
- 文档主标题(居中): follow the current assignment's user-confirmed pattern; use placeholders for missing identity fields and do not default to a naming example from another course
- 一级标题(左对齐):
一、XXX,二、XXX, 四号, pStyle="1" - 二级标题(左对齐):
(一)XXX,(二)XXX, 小四号, pStyle="2" - 三级标题及以下: 五号, pStyle="3"
- 大纲/提纲: do not add a standalone outline section to the submitted document unless the assignment or user explicitly requests one
Step 4: Homework Table of Contents (目录)
Use this step when the user asks for 目录, TOC, "做目录", or when the assignment/template clearly expects a directory.
Authority and scope
- This section is the canonical TOC profile for Chinese legal homework. If it conflicts with a generic Word-TOC workflow, this section controls.
- Do not import a generic profile's
\uswitch, SDT wrapper, forcedHeading1/2/3styles, or unrelated tab-stop defaults into a homework document.
Core strategy
- Use the homework template's
TOC10,TOC1,TOC2, andTOC3styles when they are available. - Choose the TOC depth deliberately. For an ordinary short homework, default to levels 1-2; include level 3 only when it represents a genuinely independent heading and the document, template, instructor, or user needs that detail.
- Insert a clean ordinary Word TOC complex field matching the selected depth, normally
TOC \o "1-2" \h \z; useTOC \o "1-3" \h \zonly when level 3 is justified. Do not use\uwhen the document has a standalone title. - Generate static preview TOC entries from detected headings; Word/WPS can later update page numbers.
- Keep the TOC field clean, but generate static preview entries with
TOC1/TOC2/TOC3style plus a paragraph-level right-aligned dot-leader tab stop atw:pos="8296". Some templates haveTOC2/TOC3indentation but no dot-leader tab, which makes preview page numbers appear beside the heading until Word updates the field. - Force the
目录heading and all visible TOC entry/page-number runs to black (w:color="000000"), clearing theme or hyperlink-blue color inheritance. Verify the rendered first page rather than trusting the style name alone. - The
\hswitch is optional. If Word/WPS turns entries blue after "更新目录", rerun the helper with--no-hyperlinksrather than recoloring the document-wideHyperlinkcharacter style; this preserves unrelated links. - Preserve untouched DOCX parts byte-for-byte when possible. If the document already has required TOC/heading styles and no
updateFields, avoid rewriting unrelated parts. - Do not copy old
PAGEREF _Toc...preview entries from a template; they may refer to missing bookmarks and produce Word errors. - When replacing a WPS-generated TOC, follow the outer TOC complex-field depth to its matching end. Do not stop at the first
w:fldCharType="end"; each visible entry may contain nestedHYPERLINKandPAGEREFfields with their own end markers. - Do not delete an SDT/content control merely because its visible text contains
目录; require a real TOC field instruction or aTable of Contentsgallery marker. - Fail closed if ordinary body content or non-paragraph content appears before the supposed outer TOC end. Never guess the boundary or delete through the remainder of the document.
- Do not set
w:updateFields=trueinword/settings.xml; it causes Word to ask whether to update fields. - Do not copy a whole
w:sdtcontent-control TOC wrapper unless you have verified Word opens without repair prompts. A plain TOC field is safer.
TOC page layout
- Keep the document title and
目录on the first page. - Start the body on the next page by adding
<w:pageBreakBefore/>to the first body paragraph. - Avoid inserting a visible page-break run (
<w:br w:type="page"/>) after the TOC because Quick Look/Word may display a stray square or layout artifact.
Heading detection and repair
- TOC levels map to common template styles:
一、...,二、...-> heading style1->TOC1(一)...,(二)...-> heading style2->TOC2- independent
1. ...,2. ...-> heading style3->TOC3
- Do not blindly trust existing Word styles. Users often hand-format headings, and converted documents may misuse styles.
- Do not assume that style IDs
1/2/3always mean heading levels 1/2/3. WPS may renumber style IDs (for example,1may be Normal). Match by visible numbering plus effective outline level/style name, and preserve the existing paragraph style when adding a direct outline level.- When a confirmed heading's visible text already carries
一、,(一), or1.numbering, also suppress inherited automatic numbering at paragraph level so Word/WPS cannot display a doubled prefix; do not strip the paragraph style.
- When a confirmed heading's visible text already carries
- Use a double check:
- If the effective outline level and text numbering agree, include it directly.
- If a numbered paragraph has a corroborating heading-style name or another heading outline level but lacks the expected level, preserve its current style and add the direct outline level needed by the TOC.
- A short
一、/(一)/1.prefix alone is not enough: an ordinary numbered list can look identical. Without corroborating style/outline or explicit template/user evidence, leave it unchanged and report it for confirmation. - If a paragraph has a heading/outline style but text does not look like a heading, do not include or silently downgrade it; leave it unchanged and report it for confirmation.
- If uncertain, leave it out and report it as "需人工确认标题".
- Do not include the document title, the
目录title, a drafting-only大纲/提纲, or body emphasis merely because a converter assigned it a heading style. - Do not include fourth-level or lower material. When the selected depth is 1-2, exclude level 3 even if it has a heading style.
Validation
- Verify exactly one TOC field exists, its
\orange matches the selected depth, and it does not contain\uwhen the document has a standalone title. - Verify the document title matches the final filename basename, the TOC title and entries render black, and the TOC has no unnecessary level or standalone outline entry.
- If the user will update the field in Word/WPS, verify the post-update color too; use the non-hyperlinked field when the app reapplies blue hyperlink styling.
- Verify
PAGEREF,_Toc...anchors, and missing bookmarks are not present in the generated preview entries. - Verify generated
w:pPrchild order, especiallyw:pStylebeforew:pageBreakBefore, andw:tabsbeforew:spacing. - Verify
mc:Ignorableprefixes are declared andw:rPrchild order is valid. Runningdocx_compat_check.pyis useful; a repaired Word sample should not have undefined-prefix orrFontsordering errors. - Verify body
footnoteReferenceIDs and footnote text payload are unchanged unless the task also asked for footnote work. Byte-for-byteword/footnotes.xmlequality may change if namespace prefixes are normalized to satisfy Word. - Open in Word as well as WPS when possible. If Word reports "unreadable content", first check
mc:Ignorableundefined prefixes,w:rProrder, andw:pPrchild order, then rebuild the TOC as clean plain field paragraphs and removeupdateFields.
For a deterministic helper, use:
bashpython3 scripts/add_homework_toc.py input.docx template.docx output.docx
The helper defaults to --max-level 2; pass --max-level 3 only when the third level is justified. Use --no-hyperlinks if a Word/WPS field update makes TOC entries blue.
Lessons From the 2026-06-09 TOC Regression Test
A regression test found that an automatically generated static TOC preview could differ from the TOC after Word updated the field: level-2 page numbers appeared immediately after the heading text instead of right-aligned with dot leaders. The cause was that the template's TOC2/TOC3 styles carried indentation but no right-aligned dot-leader tab. Word adds or normalizes the tab stop when the field is updated, so a static preview must add it explicitly.
Current TOC generation rule:
- Insert one clean TOC field for the selected depth (normally levels 1-2), but do not set
updateFields=true. - For every static preview entry, set
TOC1/TOC2/TOC3style and a paragraph-level right-aligned dot-leader tab stop atw:pos="8296". - Preserve level indentation:
TOC2usesw:left="420"/w:leftChars="200";TOC3usesw:left="840"/w:leftChars="400". - Normalize
w:pPrchild order automatically. Old or generated homework files may havew:indbeforew:spacing; the helper must reorder rather than fail. - Validation target: generated preview should visually resemble the Word-updated TOC, while real page numbers may still require manual field update in Word.
Step 5: Legal Citation Format
脚注必要性原则:
- 正文已完整引用法条原文 + 脚注无进一步说明 → 不设脚注(脚注无增量信息)
- 正文仅提法条编号未引原文 → 设脚注,并附法条全文(这是课程助教明确提示过的点)
- 同一法条多次出现:首次正文未引全文处设脚注(含全文);后续可不重复设注、重复简称条号,或在确有必要时写
同前注1/同前注〔1〕 - 直接引用原文:正文加引号,脚注通常不用"参见"
- 概括、转述、借鉴观点:脚注用"参见"
- 法条脚注中若写
第X条规定,...,必须先判断后文是不是官方原文:原文用规定:“……”;概括转述改成依/根据/参见第X条,可以说明……,不要把 AI 概括写成疑似法条原文 - 引注标号位置:若引注支持整句,标号置于句末标点之后;若只支持句中某一词组或法条名称,标号紧随该引用对象之后
- 脚注功能分离:不要为了减少脚注数量,把“案例出处”和“法条/司法解释依据”合并进同一个脚注;也不要把两个不同法条的全文塞进同一脚注。一个脚注原则上只服务一个引用点或同一命题下的同类来源。若正文已经概括或直接摘引法条内容,脚注可保留为简洁出处;若正文只写条号而未说明内容,再在脚注补足条文原文。
First citation: Full name + abbreviation in footnote
《中华人民共和国民法典》(以下简称《民法典》)第142条第1款。
Subsequent citations: Abbreviation only
《民法典》第147条。
Key rules:
- Do NOT use "前引" or "同上". For repeat citations in this course, use either a repeated abbreviated citation or "同前注X"/"同前注〔X〕" where helpful.
- Use 参见 for indirect citations
- Statute numbers: Arabic numerals (第142条, not 第一百四十二条)
- Case citations: full name on first use, full footnote format
- 司法解释: single书名号 〈〉 inside double for nested references
Step 6: Verify Formatting
Checklist:
- Title format: current assignment naming convention, identical to final filename basename, correct identity fields or explicit placeholders, centered, sz=30
- All headings left-aligned, bold, correct sz (28/24)
- Body text: sz=21 (五号), firstLine indent, line=300 (1.25倍)
- Body paragraphs: spacing after=156 twips, justified
- Footnotes: sz=18 (小五号), single spacing, left aligned, no first-line indent, no before/after spacing, rStyle="ab" for markers
- Footnote quote runs: all
“”‘’in footnotes are 宋体 and sz=18 - All footnote IDs unique; template-style regular ID
1is valid, while generated replacement notes may safely start at4 - Heading styles do not auto-number if headings are manually numbered
- TOC requested: selected depth is justified, title and entries are black, clean TOC field has no
\ufor a standalone title, no drafting-only outline entry, right-aligned dot leaders on preview entries, no stalePAGEREF _Toc...references - Citation placement: no adjacent footnote references at the same sentence-final position; same-claim multiple sources are bundled with semicolons
- Footnote text payloads: no leading/trailing whitespace beyond the normal delimiter after the footnote number
- Page numbers: bottom center when required by assignment length
- Open in both WPS and Word to verify
Important Notes
- Use a reference template as base when provided: do not assume any private course template exists.
- Do NOT use pStyle="1" from old assignment templates: old templates may have different style sizes (sz=44 instead of sz=28)
- Body runs inherit font size from Normal: don't set sz=21 explicitly on every body run
- Heading runs inherit everything from style: don't set rPr on heading runs
- rStyle for footnote reference is "ab": not "17" (old template) or "aa" (Hyperlink)
- Each footnoteReference needs a unique ID: Word renders only the first occurrence of each ID
- Template footnote IDs are -1/0/1: separators are
-1and0; ID1is a valid regular footnote in the course template - Use ID 4+ only as a safe generation convention: helpful when replacing all notes or repairing documents created by other tools, but not required by OOXML or the course template
- Suppress inherited numbering on confirmed manually numbered heading paragraphs: preserve their paragraph styles, and avoid global edits based only on numeric style IDs
- Remove each-page footnote restart: the course template may contain
<w:numRestart w:val="eachPage"/>; delete it for continuous homework footnotes - TOC static preview is not the authority for final page numbers: generate a clean preview with dot leaders, then let Word update the field for final pagination
- Run the compatibility check after footnotes:
docx_compat_check.pywarns about adjacent footnote references and footnote text that starts with an extra blank - Verify in both WPS and Word: these applications handle certain features differently
Bundled Resources
Scripts
scripts/add_footnotes.py: Footnote automation utilitiesscripts/add_homework_toc.py: add or rebuild a clean Word-compatible homework TOC with right-aligned dot leadersscripts/test_add_homework_toc.py: regression tests for WPS nested/static TOC cleanup, manual-numbering suppression, and field switches; run withpython3 -m unittest -v scripts/test_add_homework_toc.pyfrom the skill directoryscripts/fix_pandoc_heading_artifacts.py: remove Pandoc/WordHeading1/Heading2/Titlestyles, theme colors, highlighting, shading, and auto-numbering from homework titles/headingsscripts/docx_compat_check.py: final Word/WPS compatibility check, including stale namespace and Pandoc heading-style warnings
References
references/format_requirements.md: Comprehensive formatting requirements


