version:"1.0.0" author:jm-jsjkxyjs02-ys-1701 name: ppt-generator description: Use when the user asks to generate, create, or make a PPT/PowerPoint presentation, slides, or .pptx file. Supports both natural language descriptions and Markdown outlines as input. Covers teaching materials, business reports, project summaries, and general presentations.
Generate professional .pptx files using python-pptx. Accept input as natural language ("make a 10-slide deck about AI safety") or structured Markdown outlines.
Never skip step 3. Always get user approval on the outline before writing code.
These are mandatory defaults. Only deviate if the user explicitly overrides.
| Element | Font Size | Weight | Color |
|---|---|---|---|
| Slide title | 32pt | Bold | #1a1a2e |
| Subtitle | 18pt | Normal | #555555 |
| Body text | 14pt | Normal | #333333 |
| Small label | 11pt | Normal | #888888 |
Margins: left/right 1.5 inch, top/bottom 1.2 inch (when using manual text boxes). For built-in layouts, leave at defaults.
Four preset themes. Default is "Professional Blue". User can switch by name.
| Theme | Primary | Secondary | Accent | Background |
|---|---|---|---|---|
| Professional Blue | #1a1a2e | #16213e | #0f3460 | #ffffff |
| Warm Orange | #e07a5f | #3d405b | #81b29a | #f4f1de |
| Clean Green | #2d6a4f | #40916c | #52b788 | #ffffff |
| Dark Mode | #e0e0e0 | #bb86fc | #03dac6 | #121212 |
7w4.net小蔥技能。
Centered title, subtitle, author/date. Use PPT_LAYOUT_TITLE (layout index 0).
Title at top, bullet points in body. Use PPT_LAYOUT_BODY (layout index 1) or manual text box for multi-level lists.
Title, two text columns side by side. Use manual text boxes positioned at 0.5" and 5.0" horizontally.
Title, image on one side, text on the other. Use add_picture() with manual placement.
Title + table. Use add_table(rows, cols).
Centered "Thank You" or "Q&A" with contact info. Same layout as title slide.
from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
import os
prs = Presentation()
prs.slide_width = Inches(13.333) # 16:9 widescreen
prs.slide_height = Inches(7.5)
# Theme colors (Professional Blue)
PRIMARY = RGBColor(0x1a, 0x1a, 0x2e)
SECONDARY = RGBColor(0x16, 0x21, 0x3e)
ACCENT = RGBColor(0x0f, 0x34, 0x60)
BG = RGBColor(0xff, 0xff, 0xff)
# Helper: add a text box
def add_textbox(slide, left, top, width, height, text, font_size=Pt(14),
bold=False, color=RGBColor(0x33, 0x33, 0x33), alignment=PP_ALIGN.LEFT):
txBox = slide.shapes.add_textbox(Inches(left), Inches(top),
Inches(width), Inches(height))
tf = txBox.text_frame
tf.word_wrap = True
p = tf.paragraphs[0]
p.text = text
p.font.size = font_size
p.font.bold = bold
p.font.color.rgb = color
p.alignment = alignment
return tf
# Helper: add bullet points from a list
def add_bullet_list(slide, left, top, width, height, items, font_size=Pt(14)):
txBox = slide.shapes.add_textbox(Inches(left), Inches(top),
Inches(width), Inches(height))
tf = txBox.text_frame
tf.word_wrap = True
for i, item in enumerate(items):
if i == 0:
p = tf.paragraphs[0]
else:
p = tf.add_paragraph()
p.text = item
p.font.size = font_size
p.font.color.rgb = RGBColor(0x33, 0x33, 0x33)
p.level = 0
p.space_after = Pt(6)
return tf
slide = prs.slides.add_slide(prs.slide_layouts[6]) # blank layout
add_textbox(slide, 1.5, 2.0, 10, 1.5, "Presentation Title",
Pt(36), True, PRIMARY, PP_ALIGN.CENTER)
add_textbox(slide, 1.5, 3.5, 10, 0.8, "Subtitle or Author",
Pt(18), False, RGBColor(0x55, 0x55, 0x55), PP_ALIGN.CENTER)
add_textbox(slide, 1.5, 4.5, 10, 0.5, "2024-01-15",
Pt(11), False, RGBColor(0x88, 0x88, 0x88), PP_ALIGN.CENTER)
slide = prs.slides.add_slide(prs.slide_layouts[6])
add_textbox(slide, 0.8, 0.4, 10, 0.8, "Slide Title", Pt(32), True, PRIMARY)
items = ["Point one: key insight", "Point two: supporting detail", "Point three: takeaway"]
add_bullet_list(slide, 1.0, 1.5, 11, 4.5, items)
output_path = os.path.expanduser("~/Desktop/presentation.pptx")
prs.save(output_path)
print(f"Saved to {output_path}")
User says: "做一個關於時間管理的5頁PPT" → Claude designs the outline, presents it, then generates.
User provides:
# 時間管理
## 1. 為什麼需要時間管理
- 提高效率
- 減少壓力
## 2. 四象限法則
- 重要緊急
- 重要不緊急
...
→ Claude maps each ## heading to a slide, each bullet to a list item, and generates.
| Mistake | Fix |
|---|---|
| Text overflowing slide | Break long text into multiple slides or reduce font size |
| Missing font file for Chinese | Always use a font that supports CJK (e.g., "Microsoft YaHei", "SimSun"). Add p.font.name = 'Microsoft YaHei' for Chinese text |
| Using wrong layout index | Layout 0 = title, 1 = content, 6 = blank. Check with prs.slide_layouts if unsure |
| Forgetting Inches/Pt wrappers | All dimensions must use Inches() or Pt() from pptx.util |
| Not setting word_wrap | Long text without word_wrap = True overflows horizontally |
reference/python-pptx-api.md — Full python-pptx API quick referencescripts/ppt_helpers.py — Ready-to-import helper functions for common slide patterns這個 PPT 生成工具質量不錯,文件清晰易懂,操作步驟明確。它提供了多種幻燈片模板和配色方案,能滿足大多數演示需求。不過缺少直觀的示例展示,實際生成效果難以預覽,對新手不太友好。功能比較全面,但實操體驗還有提升空間。