Documents

公文格式Word生成

Try it

按GB/T 9704-2012党政机关公文格式标准,将文本内容转换为规范格式的Word文档。适用于需要生成公文格式(仿宋正文、黑体一级标题、楷体二级标题、标准页边距、固定行距等)的Word文件。触发词:公文格式、公文Word、GB/T 9704、党政公文、红头文件格式、仿宋3号、公文排版。

What it does

按《党政机关公文格式》(GB/T 9704-2012)标准生成Word文档。覆盖标题、正文、层次序数、页边距、行距、字体字号等全部核心格式要素。适用于政务、事业单位、国企等需要标准公文排版的场景。

The skill document

公文格式Word文档生成

概述

按《党政机关公文格式》(GB/T 9704-2012)标准生成Word文档。覆盖标题、正文、层次序数、页边距、行距、字体字号等全部核心格式要素。适用于政务、事业单位、国企等需要标准公文排版的场景。

何时使用

  • 用户要求按公文格式输出Word文档
  • 用户提到"公文格式""GB/T 9704""仿宋3号""党政公文"等关键词
  • 用户给出一篇报告/分析/总结的大纲或正文,要求按公文格式排版
  • 用户要求生成的Word文件用于领导阅览、上报、下发等正式场合

工作流程

第一步:确认内容与格式需求

从用户输入中提取以下信息:

  • 文档标题(公文标题,一般不超两行)
  • 正文内容(已有大纲或全文)
  • 是否需要主送机关(如"各有关部门:")
  • 是否有附件说明
  • 输出路径

第二步:运行生成脚本

执行 scripts/generate_gongwen.py,该脚本封装了全部公文格式设置逻辑。脚本接受一个JSON配置文件,描述文档结构(标题、各级标题、正文段落),自动生成符合公文标准的.docx文件。

调用方式:

"C:\Users\sopenclaw\.workbuddy\binaries\python\envs\default\Scripts\python.exe" "/scripts/generate_gongwen.py" ""

JSON配置结构:

{
  "output_path": "输出文件路径.docx",
  "title": "公文标题(2号方正小标宋简体居中)",
  "content": [
    {"type": "body", "text": "正文段落(3号仿宋,首行缩进2字)"},
    {"type": "h1", "text": "一、一级标题(3号黑体)"},
    {"type": "h2", "text": "(一)二级标题(3号楷体)"},
    {"type": "h3", "text": "1.三级标题(3号仿宋)"},
    {"type": "blank", "text": ""},
    {"type": "body", "text": "另一段正文..."}
  ]
}

content 数组支持的类型:

  • title — 2号方正小标宋简体,居中(一般只用一次,放在最前)
  • h1 — 3号黑体,首行缩进2字,对应"一、二、三、"
  • h2 — 3号楷体,首行缩进2字,对应"(一)(二)(三)"
  • h3 — 3号仿宋,首行缩进2字,对应"1. 2. 3."
  • body — 3号仿宋,首行缩进2字,正文段落
  • blank — 空行

第三步:验证与交付

生成后检查文件大小是否正常(一般>10KB),然后用 present_files 交付给用户。

格式规范速查

详细规范见 references/gongwen_format_spec.md。核心要点:

要素规范
页面A4,上37mm,左28mm,版心156×225mm
标题2号(22pt)方正小标宋简体,居中
正文3号(16pt)仿宋,首行缩进2字,回行顶格
一级标题3号黑体,"一、""二、""三、"
二级标题3号楷体,"(一)""(二)""(三)"
三级标题3号仿宋,"1.""2.""3."
四级标题3号仿宋,"(1)""(2)""(3)"
行距固定值29pt(约每面22行)
字色黑色

字体说明

Windows系统自带仿宋(simfang.ttf)、黑体(simhei.ttf)、楷体(simkai.ttf),可直接使用。

"方正小标宋简体"为公文标题标准字体,需安装。当前系统已安装(用户字体目录:%LOCALAPPDATA%\Microsoft\Windows\Fonts\方正小标宋简体.TTF)。脚本中 TITLE_FONT 已设为该字体。如在其他机器上运行且未安装该字体,Word会自动回退到默认字体渲染,届时标题效果可能略有差异。

资源文件

scripts/generate_gongwen.py

公文格式Word生成脚本。读取JSON配置,输出符合GB/T 9704标准的.docx文件。依赖 python-docx(需安装到 venv:pip install python-docx)。

references/gongwen_format_spec.md

GB/T 9704-2012公文格式完整规范摘要,包含版面、字体、标题、正文、附件等全部要素的详细说明。生成复杂公文时参考此文件。

Related skills

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

More from zigu-creator

Browse all skills

Automatically scrape, process, and generate daily news digests from Chinese news sources. Covers industry dynamics, policy updates, economy, tech, energy, an...

by zigu-creator26 installs1 stars

Automatically scrape, process, and generate daily news digests from Chinese news sources. Covers industry dynamics, policy updates, economy, tech, energy, and pricing information. Use when: user asks for daily news summary, news digest, 每日新闻摘要, 新闻汇总, 新闻摘要, or wants to set up automated news monitoring from Chinese news websites. Outputs formatted summaries with source attribution and original links.

by zigu-creator4 installs