word-auto-format

👤 user_e41a5bf9 📦 v1.0.0 ⭐ 4.4 ⬇️ 505 下载
📄 办公效率 免费

📖 技能介绍


author:jm-jsjkxyjs01-wsj-402 name: word-auto-format description: > This skill should be used when the user wants to automatically format, typeset, or beautify a Word (.docx) document. Triggers include: "帮我排版这个Word", "自动格式化文档", "统一字体行距", "论文/报告排版", "Word排版", "整理文档格式", "format this Word file", "auto typeset", "standardize document style". The skill provides a Python script (word_formatter.py) that handles font unification, heading detection, line spacing, page margins, table formatting, and caption centering in one command. agent_created: true


Word 自动排版 Skill

概述

本 skill 提供一键 Word 文档自动排版能力,基于 python-docx 实现,支持三种内置排版方案(通用/学术/商务),核心脚本为 scripts/word_formatter.py


排版能力清单

功能 说明
页面边距 统一设置上下左右边距
正文字体 中文字体(东亚字体)+ 英文字体分别设置
正文行距 固定行距(1.5倍行距)
首行缩进 学术/通用方案自动缩进 2 字符
标题识别 自动识别"第一章""一、""1.1"等常见格式
标题样式 黑体/微软雅黑,多级颜色与间距
图表标题 自动居中"图1、表1、Figure 1"格式
表格样式 单元格垂直居中,字号略小
原文备份 操作前自动生成 _backup.docx

工作流程

第一步:确认依赖

检查用户环境是否已安装 python-docx

python -c "import docx; print('OK')"

若未安装,执行:

7w4.net小葱技能站收录全网优质技能,值得收藏。

pip install python-docx

第二步:选择排版方案

根据用户需求选择方案:

  • academic — 学术论文、毕业设计、学术报告(宋体/Times New Roman,黑体标题居中,严格行距)
  • business — 商务报告、策划方案、PPT 稿(微软雅黑/Calibri,蓝色标题,无首行缩进)
  • default — 通用文档(介于两者之间)

若用户未指定,询问文档用途后再选择,或直接使用 default

第三步:执行排版脚本

脚本路径:scripts/word_formatter.py(位于本 skill 目录)

python "<skill_dir>/scripts/word_formatter.py" "<input.docx>" ["<output.docx>"] --profile <profile>

示例:

# 学术论文
python word_formatter.py 论文.docx 论文_排版.docx --profile academic

# 商务报告(输出文件自动命名为 报告_formatted.docx)
python word_formatter.py 报告.docx --profile business

# 通用(自动输出 文档_formatted.docx)
python word_formatter.py 文档.docx

第四步:向用户报告结果

脚本执行完毕后,输出包含以下统计信息:

排版统计:
  一级标题:X 处
  二级标题:X 处
  三级标题:X 处
  正文段落:X 段
  图表标题:X 处
  表格:    X 个

告知用户: 1. 输出文件路径 2. 原文备份位置 3. 如有需要可调整方案重跑


自定义排版需求处理

若用户有特殊要求(如特定字体、特定行距、特定颜色),直接修改 word_formatter.py 中的 PROFILES 字典对应方案,或新增自定义方案后使用 --profile 调用。

详细参数参考:references/formatting_guide.md


已知限制

  • 仅支持 .docx,不支持旧版 .doc 格式(如遇到 .doc,提示用户先在 Word 中另存为 .docx
  • 标题自动识别基于正则,若文档使用非标准格式(如纯数字行、全大写英文行),可能无法准确识别
  • 复杂排版(多栏、文本框内容)暂不处理
  • 脚本基于 python-docx 0.8.x,建议使用该版本

参考资源

  • scripts/word_formatter.py — 核心排版脚本,可直接执行
  • references/formatting_guide.md — 完整参数说明与自定义方案指南

🤖 AI 评测

这是一款实用的 Word 排版工具,能快速统一文档格式,对论文、报告排版很有帮助。预设了三种场景方案,基本能满足日常需求,文档说明也很清晰。不过它只支持新版 docx 格式,对复杂排版(如文本框)支持有限。总体来说质量不错,是值得一试的排版辅助工具。

📊 多维度评分

适应性4.7
规范性4.4
有效性4.3
可靠性4.2
可信度4.9

📁 包含文件 (3 个)

📄 SKILL.md 4 KB
📄 references/formatting_guide.md 4 KB
📄 scripts/word_formatter.py 10.6 KB