下载地址
https://www.zhengdianxue.com/wp-content/uploads/skills/user_2bd9dfb1--gongwen-paiban-xiongwang.zip将提示词发送给你的 AI 安装该 skills
请根据 https://skillhub.cn/install/skillhub.md,安装 @user_2bd9dfb1/gongwen-paiban-xiongwang。公文排版-熊王 是一套按 GB/T 9704-2012《党政机关公文格式》自动排版中文公文的技能。用户只需提供一份 Word(.docx)原稿,技能即可自动套用标准版面:A4 纸张、上37/下35/左28/右26mm 页边距、156×225mm 版心、22行×28字;生成红色小标宋发文机关标志、发文字号与红色分隔线、二号小标宋标题、三号仿宋正文(首行缩进2字符)、黑体/楷体结构层次、以成文日期为准居中的落款署名、版记与奇偶页页码。
内置脚本参数化生成,并固化两条最易错规则:署名以成文日期中心线居中(非整页居中)、关闭中西文自动间距。适用于通知、通报、报告、请示、函等公文的标准化排版场景。
阅读全文 (展开查看完整说明)
概述
Purpose
Reformat any raw Word document into a standard 党政机关公文 that complies with GB/T 9704-2012《党政机关公文格式》. The skill encodes the precise page geometry, font/size rules, line metrics, element ordering, and — most importantly — the two subtle rules that even experienced users get wrong (signature alignment and digit↔Chinese auto-spacing).
When to use
- The user provides a
.docx(or its text) and asks to "按公文格式排版 / 党政机关公文格式 / GB/T 9704 / 红头文件". - The document is a 通知 / 通报 / 报告 / 请示 / 函 / 纪要 / 决定 etc.
- Even when the source is a template full of
X/××placeholders — keep the
placeholders and typeset the structure; the user fills real values later.
Reference material
references/gbt9704_spec.md— the exact numeric spec (margins, 版心, font sizes,
line spacing, the signature-centering formula, auto-spacing fix, 页码 rules). Read this before generating; it is the source of truth.
scripts/typeset_gbt9704.py— a reusable, parameterized python-docx module.
Call build_docx(spec, out_path) where spec is a dict describing the document elements. A complete demo (the training-notice example) is included at the bottom.
Workflow
- Read the spec reference. Load
references/gbt9704_spec.mdto fix the exact
numbers and the two common-mistake rules in mind.
- Extract the source. Read the user's
.docxwith python-docx (or ask for the
text). Identify: 发文机关标志 / 发文字号 / 标题 / 主送机关 / 正文与层次 / 署名 / 成文日期 / 印发机关 / 印发日期. For templates, keep ×× / × placeholders.
- Build the spec dict. Map the extracted elements into the
specstructure used
by build_docx (see script docstring). Use type per paragraph: h1 (一、黑体), h2 ((一)楷体), body (仿宋, first-line indent 2 chars).
- Generate. Run
build_docx(spec, out_path). The script applies page geometry,
fonts, the red separator, correct signature centering, auto-spacing off, and 页码.
- Verify visually. Convert the docx → PDF (Windows: Word COM via PowerShell;
SaveAs filetype 17). Render the PDF pages to PNG with fitz (PyMuPDF) at 2× and inspect: 版心 edges, red-header position, no "2026 年" gap, signature centered on date, 版记 on last page. Iterate on spec / script if anything is off.
- Deliver the docx. Present the generated
.docxto the user.
Critical rules (do not skip)
- 署名 vs 日期 alignment (7.3.5.1): 成文日期 = 右空四字. 发文机关署名 must be
以成文日期为准居中 — its horizontal center aligns with the date's center, NOT the page center. Compute left_indent so 署名.center == 日期.center (formula in the reference). A page-centered signature is wrong and looks misaligned.
- 关闭自动间距: Word inserts a gap between Western digits and Chinese (e.g.
2026 年). Set w:autoSpaceDE and w:autoSpaceDN to off on any paragraph that mixes digits and Chinese (署名, 成文日期, 版记). This is handled by disable_auto_spacing() in the script.
- 印章位置: This skill lays out a 加盖印章公文 (seal position reserved, no image
drawn). Tell the user to drop a red seal that 下压 both 署名 and 成文日期.
Environment notes
- Requires
python-docxandpymupdf(fitz). Use the managed venv:
C:Usersxiong.workbuddybinariespythonenvsdefaultScriptspython.exe.
- PDF conversion for verification needs Microsoft Word on Windows (COM). If Word is
unavailable, skip the visual check and clearly tell the user.
- Fonts: rely on 仿宋 / 楷体 / 黑体 / 小标宋 (e.g. 方正小标宋简体). If a font is missing,
Word substitutes glyphs (e.g. hex brackets 〔〕 may render as ()); flag this to the user.