Install any skill in seconds. Free to start, no credit card required.
Get Started Free →用 python-pptx 写"现代化中文制度 / 党政 / 企业宣贯 PPT"(含决议书提报、评审报告、管理办法、培训宣贯等 23 页量级 deck)。当用户要求程序化生成 PPT 且抱怨"老土 / 字体丑 / 表格乱 / 文字溢出 / 中文字体 fallback / 缺架构图"时启用——`python-pptx` 默认 API 一堆坑必须主动避开。提供:路径决策 / 设计 token / 12 个 helper 全套 / 7 个致丑反模式 / 12 个关键技巧 / LibreOffice 渲染验证闭环 / 跨平台中文字体生效 lxml 写法 / 配套 draw.io 画架构图选型(中文字体、配色、8 大坑、嵌入 PPT 链路)。
.claude/skills/pcliangx-agf-writing-pptx-reports/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 107% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 96% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 161% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 266% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 79% | 0% |
> 沉淀自《AI 4A 架构评审管理办法》v1.0 PPT 实战(23 页,GAC 红主调,含双视图嵌入流程图),全部踩过 + 验证过的坑与方法。重型参考材料在 references/,按下方索引按需 Read 全文,不要凭记忆写代码。
| 信号 | 用本 skill | |---|:--:| | 需要程序化生成 PPT(数据驱动 / 模板批量 / 内容版本化) | ✅ | | 中文制度 / 党政 / 企业内部宣贯 deck | ✅ | | 用户反馈"老土 / 字体丑 / 表格乱 / 文字溢出 / 中文字体 fallback" | ✅ | | 内容会反复迭代,PPT 必须从源码可重生成 | ✅ | | 需要 mermaid 流程图嵌入 + 双视图卡片化 | ✅ | | 高度自由排版 / 视觉冲击型营销 deck | ❌ 直接 Keynote / Figma | | 复杂动画 / 视频嵌入 | ❌ python-pptx 弱项 | | 一次性单页海报 | ❌ 直接画 | | 要 docx / xlsx | ❌ 转 writing-docx-reports / xlsx skill |
| 路径 | 何时选 | 代价 | |---|---|---| | 手动复制 .pptx 模板编辑 | 一次性 deck / 设计师介入 / 不需重生成 | 几分钟;后续维护成本高 | | pptx skill 局部改 | 已有 .pptx 做小幅修改(≤ 5 张 slide / 仅换文字)| 中等;不适合从零生成 | | 基于模板 + python-pptx 混合 ⭐ | 仓库已有 .pptx 模板 / 视觉风格已定 / 需版本化 + 重生成 | 一次 ~500 行;保留模板视觉投入 + 代码可重跑 | | python-pptx 全定制 | 没现成模板 / 视觉自己定义 / 跨平台中文 / 23+ 页量级 | 一次 ~800 行 Python,复用率 90% |
判定经验:
template/ 已有 1 个 .pptx 模板(Template.pptx,coral 团队风)→ 默认走"基于模板 + python-pptx 混合",不要重造视觉template-*-guide.md| 场景 | 必读(Read 全文) | |---|---| | 走"基于模板 + python-pptx 混合"路径(动手前) | references/template-based-generation.md(7 步流程 / 模板分析三件套 / Placeholder vs Shape / 关键文件指针)+ 对应 template-*-guide.md(如 template-team-guide.md)| | 写 helper / 设计 token / 字号 layout / 品牌色板(任何写代码前) | references/design-tokens-and-techniques.md(设计 token + 12 个关键技巧完整代码 + 品牌色获取 3 步)+ template.py(可直接 python3 template.py 跑样例)| | deck 缺架构 / 流程 / 矩阵图(走 draw.io 前) | diagram-generation-guide.md(500 行:安装 CLI / mxGraph 模板 / AGF token / 字号体系 / 8 大致丑坑 / 批量工作流 / 嵌入链路)| | mermaid 出图嵌 PPT / 多 PNG 合 PDF 提报 / 查外部资源链接与沉淀来源 | references/rendering-and-embedding.md | | 操作 .pptx 底层(unpack / thumbnail / pack) | .claude/skills/pptx/SKILL.md(Anthropic 低层 skill)|
| 用途 | 工具 | 装法 | |---|---|---| | PPT 生成 | python-pptx ≥ 1.0 | pip3 install --user --break-system-packages python-pptx | | XML 微调(EA 字体 / 表格属性 / 阴影) | lxml | 通常已装 | | PPT → PDF(实际渲染验证)| soffice(LibreOffice)| brew install --cask libreoffice | | PDF → PNG(视觉验证)| pdftocairo(poppler)| brew install poppler | | 多 PNG → PDF 合并 | sips(系统自带)+ pdfunite | brew install poppler | | mermaid 流程图 | mmdc | brew install mermaid-cli |
⚠ 不要装 PrinceXML(商业 + 免费版水印);不要走 pandoc --pdf-engine=prince 这条路。
diagram-generation-guide.md 全文(见上方索引)_fix_ph_font(ph, name="PingFang SC"));别图用 Heiti SC、PPT 用 PingFang SC 造成跨页面字体跳变| # | 反模式 | 为什么丑 | 正确做法 | |:-:|---|---|---| | 1 | 顶部厚色带(≥0.5")每页都重复 | 压死页面空间 + 视觉疲劳 | 6pt 极细线 + 右上 140pt 装饰大数字 | | 2 | 每页同一 header(title, page) 通用模板 | 章节同质化、无层次感 | 章节扉页与内容页分两种 layout | | 3 | 表格全网格(Excel 风)+ 默认 banding | 老土 + 信息密度低 | 表头深色 + 0 内边框 + 自定义斑马纹 | | 4 | 一页 5+ 种饱和色(绿/蓝/红/橙/紫) | 眼花、权重失序 | 1 主色 + 1 强调色 + 灰阶 + 白 | | 5 | 全屏文字墙(一页 >100 字)| 没人会读完 | 卡片化(每个信息单元独立矩形) | | 6 | 标题用艺术字 / 阴影 / 3D / 渐变铺底 | 党政"信封风" | 简洁字体 + 1pt 横线分隔 | | 7 | emoji 滥用(🚀 ✅ 🎉 等活泼感)| 制度文件不严肃 | 仅 ⚠ ⛔ 🔒 类警示性图标 |
| # | 坑 | 正解 | |:-:|---|---| | 1 | font.name 只写 <a:latin>,中文跨平台 fallback 丑字体 | set_font 用 lxml 显式写 <a:ea> + <a:cs>(技巧 #1)| | 2 | set_font(run) 改不动 placeholder 中文字体(<a:ea> 继承自 master)| placeholder 一律 _fix_ph_font(ph, ...),自加 textbox 才用 set_font(run, ...) | | 3 | textbox 默认 margin 非 0 → 文字神秘偏右/偏下 | margin_left/right/top/bottom = Emu(0) | | 4 | 大字号装饰数字被自动换行("01" → 两行)| word_wrap=False;宽度 ≥ 字符数 × 0.6 × 字号pt / 72 | | 5 | 表格默认 banding 出怪横纹 / 行高失控 | tblPr 关 firstRow/bandRow + 显式 row.height,斑马纹手动填色 | | 6 | shape.fill = None 不是"无填充",是"默认"(会有边)| fill.background() / line.fill.background() | | 7 | 模板自带样例 slide 污染输出 | 加载后立即 clear_template_slides(prs)(template.py 提供)| | 8 | LibreOffice 渲染页数 < len(prs.slides) 误判为代码 bug | 模板含"工具说明页"不被渲染,先看 template-*-guide.md |
最致命的错误:只用 python-pptx 读回验证文件合法性,不看实际渲染。字符溢出 / 表格被截 / 文字遮挡 / 行高失控 / 中文字体 fallback——只能靠 LibreOffice 渲染 PDF + 看 PNG 才能发现。
bashpython3 build-ppt.py # 1. 生成 cd /tmp && rm -rf preview && mkdir preview && cd preview soffice --headless --convert-to pdf /path/to/output.pptx # 2. 转 PDF(实际渲染) pdftocairo -png -r 100 output.pdf p # 3. 转 PNG(视觉) # 4. 用 Read tool 看关键页(封面、表格页、嵌入图页、警示页) # 5. 发现问题 → 改 build-ppt.py → 回到 1
每页 3 步检查:✓ 文字是否被截断 / 溢出框 / 遮挡? ✓ 中文字体是否正确(不是 fallback 到丑字体)? ✓ 表格 / 列宽是否合理,斑马纹是否生效?
通用(所有路径都查):
<a:ea> + <a:cs>)firstRow / bandRow(防 banding)word_wrap=Falsemargin_left/right = 0line_spacing 显式设置(标题 1.0 / 正文 1.45)N / TOTALheight=Inches(N) 等比缩放(不变形)python3 build-ppt.py 一键重生成基于模板路径专项(增加 4 项):
clear_template_slides(prs) 清空所有样例 slide_fix_ph_font(ph, ...) 修字体(不是 set_font(run, ...))len(prs.slides) —— 不一致时确认是"模板含工具说明页"而非代码 bugtemplate-*-guide.md(如 template-team-guide.md),知道该模板的可用 layout / 配色 / 字体坑把上文 Checklist 反过来念即是 anti-prompt(每条 [ ] → "不要 X"),不在此重列。Checklist 未覆盖的唯一一条额外禁令:
- 不要 commit 渲染产物(HTML / PDF / .pyc)— 在 .gitignore 里| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 30,441 | 6,144 | -80% | 1 | 1 | 0% | 6,220 | 3,385 | -46% | 0 | 0 | — |
case-02 | fail→fail | 32,143 | 36,313 | +13% | 1 | 1 | 0% | 6,209 | 9,306 | +50% | 0 | 0 | — |
case-03 | fail→fail | 33,265 | 28,011 | -16% | 1 | 1 | 0% | 6,213 | 8,700 | +40% | 0 | 0 | — |
case-04 | pass→pass | 13,961 | 16,167 | +16% | 1 | 1 | 0% | 2,146 | 6,176 | +188% | 0 | 0 | — |
case-05 | pass→pass | 13,061 | 8,327 | -36% | 1 | 1 | 0% | 1,827 | 4,379 | +140% | 0 | 0 | — |
case-06 | pass→pass | 25,777 | 23,703 | -8% | 1 | 1 | 0% | 4,646 | 7,686 | +65% | 0 | 0 | — |
case-21 | pass→pass | 9,249 | 3,067 | -67% | 1 | 1 | 0% | 1,314 | 3,540 | +169% | 0 | 0 | — |
case-07 | fail→pass | 15,179 | 13,588 | -10% | 1 | 1 | 0% | 2,707 | 5,599 | +107% | 0 | 0 | — |
case-08 | fail→pass | 13,942 | 9,003 | -35% | 1 | 1 | 0% | 2,354 | 4,622 | +96% | 0 | 0 | — |
case-09 | pass→pass | 9,279 | 4,609 | -50% | 1 | 1 | 0% | 1,609 | 3,851 | +139% | 0 | 0 | — |
case-10 | pass→pass | 9,865 | 7,139 | -28% | 1 | 1 | 0% | 1,652 | 4,406 | +167% | 0 | 0 | — |
case-11 | fail→pass | 12,980 | 15,789 | +22% | 1 | 1 | 0% | 2,286 | 5,972 | +161% | 0 | 0 | — |
case-12 | pass→pass | 13,858 | 5,998 | -57% | 1 | 1 | 0% | 2,261 | 4,059 | +80% | 0 | 0 | — |
case-13 | fail→pass | 6,533 | 4,540 | -31% | 1 | 1 | 0% | 1,021 | 3,739 | +266% | 0 | 0 | — |
case-14 | fail→pass | 15,723 | 9,506 | -40% | 1 | 1 | 0% | 2,604 | 4,665 | +79% | 0 | 0 | — |
case-15 | fail→pass | 16,297 | 16,883 | +4% | 1 | 1 | 0% | 2,397 | 5,759 | +140% | 0 | 0 | — |
case-16 | fail→pass | 16,363 | 13,695 | -16% | 1 | 1 | 0% | 2,339 | 5,450 | +133% | 0 | 0 | — |
case-17 | fail→pass | 17,850 | 26,080 | +46% | 1 | 1 | 0% | 2,902 | 7,827 | +170% | 0 | 0 | — |
case-18 | pass→pass | 6,704 | 5,500 | -18% | 1 | 1 | 0% | 961 | 3,881 | +304% | 0 | 0 | — |
case-19 | pass→pass | 14,290 | 13,485 | -6% | 1 | 1 | 0% | 2,083 | 5,095 | +145% | 0 | 0 | — |
case-20 | fail→fail | 10,845 | 13,047 | +20% | 1 | 1 | 0% | 1,603 | 4,935 | +208% | 0 | 0 | — |
case-22 | fail→pass | 14,301 | 8,814 | -38% | 1 | 1 | 0% | 2,668 | 4,461 | +67% | 0 | 0 | — |
case-23 | pass→pass | 12,891 | 6,827 | -47% | 1 | 1 | 0% | 2,046 | 4,220 | +106% | 0 | 0 | — |
case-24 | pass→pass | 13,083 | 8,064 | -38% | 1 | 1 | 0% | 1,949 | 4,285 | +120% | 0 | 0 | — |
case-25 | pass→pass | 12,405 | 5,986 | -52% | 1 | 1 | 0% | 1,834 | 4,030 | +120% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted, and 24 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +36 percentage points is the difference between those two pass rates over the 24 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.