本文へ移動
cccskills
無料GitHub で公開

DOCX工具

创建、编辑、校验和转换 Word DOCX,支持把完整 LaTeX 论文转换为 DOCX,以及数学建模论文模板、原生公式、三线表、修订和批注。

インストール方法を見る

含まれるファイル(66)

  • SKILL.md6.6 KB
  • LICENSE.txt1.4 KB
  • scripts/__init__.py1 B
  • scripts/accept_changes.py4.9 KB
  • scripts/check_env.py972 B
  • scripts/comment.py11.2 KB
  • scripts/equations.py49.9 KB
  • scripts/inspect_template_format.py7.2 KB
  • scripts/office/helpers/__init__.py0 B
  • scripts/office/helpers/merge_runs.py5.4 KB
  • scripts/office/helpers/simplify_redlines.py5.6 KB
  • scripts/office/pack.py4.9 KB
  • scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd1.9 KB
  • scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd2.5 KB
  • scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd2.8 KB
  • scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd1.3 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd73.2 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd6.8 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd50.1 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd624 B
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd148.5 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd1.2 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd8.7 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd14.4 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd81.7 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd1.2 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd7.2 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd6.2 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd1.2 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd880 B
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd2.5 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd3.4 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd7.3 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd22.8 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd1.3 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd236.6 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd25.5 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd24.7 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd535 B
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd5.6 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd3.9 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd167.4 KB
  • scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd4.5 KB
  • scripts/office/schemas/mce/mc.xsd3.1 KB
  • scripts/office/schemas/microsoft/wml-2010.xsd25.9 KB
  • scripts/office/schemas/microsoft/wml-2012.xsd3.7 KB
  • scripts/office/schemas/microsoft/wml-2018.xsd901 B
  • scripts/office/schemas/microsoft/wml-cex-2018.xsd1.7 KB
  • scripts/office/schemas/microsoft/wml-cid-2016.xsd1002 B
  • scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd600 B
  • scripts/office/schemas/microsoft/wml-symex-2015.xsd745 B
  • scripts/office/soffice.py5.3 KB
  • scripts/office/unpack.py4.0 KB
  • scripts/office/validate.py3.8 KB
  • scripts/office/validators/__init__.py336 B
  • scripts/office/validators/base.py34.2 KB
  • scripts/office/validators/docx.py16.0 KB
  • scripts/office/validators/pptx.py9.6 KB
  • scripts/office/validators/redlining.py8.7 KB
  • scripts/paper_format.py19.9 KB
  • scripts/self_check.py4.2 KB
  • scripts/templates/comments.xml2.5 KB
  • scripts/templates/commentsExtended.xml2.5 KB
  • scripts/templates/commentsExtensible.xml2.6 KB
  • scripts/templates/commentsIds.xml2.6 KB
  • scripts/templates/people.xml115 B

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

DOCX 工具

路径与写入

  • 当前目录为本工具根目录,只读。
  • 模板和脚本从本目录读取。
  • 生成或修改后的 DOCX 必须写入用户 PROJECT_ROOT。
  • 默认不覆盖输入文件或 Skill 文件。

数学建模论文推荐流程

采用“当届官方参考模板 + python-docx 构建 + OMML 公式 + OOXML 校验 + 渲染抽检”。官方模板控制页面、样式、分节、页眉页脚和编号;代码负责稳定写入内容。

from pathlib import Path
import sys

scripts = Path("<SKILL_ROOT>") / "tools" / "docx" / "scripts"
sys.path.insert(0, str(scripts))
import paper_format as pf

doc = pf.new_document(
    contest="cumcm",
    template_path=Path("<PROJECT_ROOT>") / "当届官方模板.docx",
    preserve_template_content=False,
)
# 此示例只借用模板样式后追加正文。
# 若官方模板包含固定摘要页或编号页,应改为 True 并在原位置填充。
pf.title(doc, "论文题目")
pf.abstract_title(doc)
pf.body(doc, "摘要正文。")
pf.keywords(doc, "优化;预测")
pf.equation(doc, r"\min f(x)=\sum_{i=1}^{n}x_i^2")
pf.three_line_table(doc, [["符号", "说明"], ["x", "决策变量"]])
pf.save_document(doc, Path("<PROJECT_ROOT>"), contest="cumcm")

公式

直接写入

scripts/equations.py 把常用 LaTeX 子集转成 Word 原生 OMML。未知命令、未闭合分组和不支持环境会报错,不会静默生成错误文本。

python scripts/equations.py replace "输入.docx" `
  --replace "EQ_OBJECTIVE" "\min f(x)=\sum_{i=1}^{n}x_i^2" `
  --output "<PROJECT_ROOT>/输出.docx"

同一占位符出现多次时会全部替换。支持分式、上下标、根式、n 次根、常用希腊字母与关系符号、反三角函数和常见矩阵,包括 \nu、\mu、\approx、\arcsin、\arccos、\arctan。

复杂公式

复杂 LaTeX 优先使用 Pandoc 的成熟转换:

python scripts/equations.py generate "论文.md" `
  --output "<PROJECT_ROOT>/论文.docx" `
  --template "官方模板.docx"

转换后仍须校验和渲染抽检。

完整 LaTeX 论文转 DOCX

此功能需要预先安装 Pandoc,并保证 pandoc 命令可用;可先运行 python scripts/check_env.py 检查。工具将 .tex 主入口转换为 DOCX,从 LaTeX 项目目录读取相对图片,使用 citeproc 处理 BibTeX 引用,并把公式写为可编辑 OMML。传入当届官方 DOCX 作为参考模板,以继承 Word 样式和页面设置:

python scripts/equations.py convert-latex `
  "<PROJECT_ROOT>/完整论文-LaTeX/main.tex" `
  --output "<PROJECT_ROOT>/完整论文.docx" `
  --template "<PROJECT_ROOT>/当届官方模板.docx" `
  --timeout 120

工具会在转换前递归展开项目内的 \input 与 \include,但保留注释和字面量环境中的原文,拒绝越界路径和循环包含;转换成功后生成同名 .conversion.json,记录全部输入文件、输入/输出/模板哈希、Pandoc 路径与版本、命令、耗时和警告。DOCX 与清单成对替换,失败时恢复旧版本。默认拒绝覆盖已有输出;确认替换旧版本时才使用 --overwrite。

Pandoc 向标准错误输出的任何警告都会默认阻断发布,失败时不会留下 DOCX。只有逐项检查后,才能用精确正则和具体理由覆盖:

python scripts/equations.py convert-latex `
  "<PROJECT_ROOT>/完整论文-LaTeX/main.tex" `
  --output "<PROJECT_ROOT>/完整论文.docx" `
  --template "<PROJECT_ROOT>/当届官方模板.docx" `
  --allow-warning "<已核对的精确警告正则>" `
  --override-reason "<不影响交付的证据>"

自定义宏、LaTeX 专用环境、浮动体位置、交叉引用和参考文献样式可能需要在 Word 中修正。未提供 CSL 时 citeproc 使用 Pandoc 默认引文样式,因此竞赛要求特定引文格式时仍须在 Word 中核对。转换完成后必须执行 DOCX 结构校验、清单核对和渲染抽检,不能把“成功生成文件”等同于版式合格。

转换后以及交付前都要重新验证清单;源码、任一子文件、图片、BibTeX、参考模板、DOCX 或清单发生变化后必须重新转换:

python scripts/equations.py verify-conversion `
  "<PROJECT_ROOT>/完整论文.docx"

解包、校验与重打包

DOCX/XLSX 共用的 OOXML 基础工具只保留在 scripts/office/:

python scripts/office/unpack.py "输入.docx" "<PROJECT_ROOT>/unpacked"
python scripts/office/validate.py "<PROJECT_ROOT>/输出.docx"
python scripts/office/pack.py "<PROJECT_ROOT>/unpacked" "<PROJECT_ROOT>/输出.docx" --original "输入.docx"

不要在不理解 OOXML 关系和内容类型的情况下直接修改压缩包。

修订

python scripts/accept_changes.py "输入.docx" "<PROJECT_ROOT>/已接受修订.docx"

工具使用隔离的 LibreOffice 配置。超时、非零退出或残留修订标记都会失败,失败时不发布输出文件。

批注

先解包,再添加批注元数据和文档标记。父批注不存在或批注 ID 重复时,工具会在写入前失败。

python scripts/comment.py "<PROJECT_ROOT>/unpacked" 0 "批注意见"
python scripts/comment.py "<PROJECT_ROOT>/unpacked" 1 "回复意见" --parent 0

必做验证

python scripts/check_env.py
python scripts/self_check.py
python scripts/office/validate.py "<PROJECT_ROOT>/完整论文.docx"
python scripts/paper_format.py validate "<PROJECT_ROOT>/完整论文.docx" --contest cumcm --rendered-pages <DOCX实际渲染页数>
python scripts/equations.py verify-conversion "<PROJECT_ROOT>/完整论文.docx"

verify-conversion 仅适用于由本工具的 Pandoc 转换生成、带 .conversion.json 的 DOCX;直接由 paper_format.py 构建时省略。paper_format.py validate 输出结构化指标,并在官方前置结构、篇幅质量目标、公式/图/表数量、图表编号与正文引用、参考文献双向对应或实际页数任一不满足时返回非零退出码。所有竞赛默认至少 8 幅图;CUMCM 默认的 15000 字词单位和约 20 页只是质量目标。以 2026 年官方规范为例,正文不超过 30 页才是硬约束。只有当届官方规则或用户明确要求允许偏离时才能调整目标并记录依据。结构校验后,把 DOCX 渲染成 PDF 或图片抽检分页、公式、表格、图片、页眉页脚和字体替换。

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

读取、创建、修改和验证 XLSX,支持模板保留、公式重算和错误检查。

日本語の概要は準備中です。原文の説明を表示しています。

XiaoMaColtAI/math-modeling-skill1,8592026年10月11日 更新

从官方或内置模板创建、编译和校验数学建模 LaTeX 论文项目,并可配合 DOCX 工具把完整 LaTeX 论文转换为 Word。

日本語の概要は準備中です。原文の説明を表示しています。

XiaoMaColtAI/math-modeling-skill1,8592026年10月11日 更新

当用户要求数学建模、建模竞赛、建模分析、代码求解、结果可视化或生成数学建模论文时使用。支持完整三阶段流程、单独执行任一角色,以及在关键节点使用独立 Subagent 进行阶段内质检;默认只启用质检 Subagent,用户可明确选择额外协作。

日本語の概要は準備中です。原文の説明を表示しています。

XiaoMaColtAI/math-modeling-skill1,8592026年10月11日 更新

pdf

無料

Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.

日本語の概要は準備中です。原文の説明を表示しています。

XiaoMaColtAI/math-modeling-skill1,8592026年10月11日 更新

使用 OpenAlex 与 AnySearch 两个真实数据源并行搜索、交叉匹配和输出可追溯论文元数据。

日本語の概要は準備中です。原文の説明を表示しています。

XiaoMaColtAI/math-modeling-skill1,8592026年10月11日 更新

建模手

無料

数学建模的题目理解、模型选择和算法设计阶段。输出题目分析报告与术语表格。

日本語の概要は準備中です。原文の説明を表示しています。

XiaoMaColtAI/math-modeling-skill1,8592026年10月11日 更新

XiaoMaColtAI のスキルをすべて見る

このスキルの問題を報告する