pptx-math
νκ΅μ΄ λ¬Έμλ README.ko.md
Put real PowerPoint equations into .pptx files from LaTeX β not pictures of equations.
add_native_equation(box.text_frame,
r"\Pr(y=1) = \sigma(\alpha + \beta_j \cdot z_j + \gamma \cdot \mathbf{x})")
The result is a native OMML equation: double-click it in PowerPoint and the equation
editor opens. It is vector (never pixelates), it follows the theme color, and it is
editable by whoever opens the deck.
No pandoc, no LaTeX distribution, no MathType. Standard library + python-pptx only.
Why this exists
python-pptx has no equation API. Every workaround is worse than it looks:
| Approach | Editable | Quality | Verdict |
|---|
| Native OMML (this repo) | Yes β equation editor | Vector, LaTeX-grade | β
|
| Rendered PNG (matplotlib) | No β it's an image | Rasterizes when zoomed | Fallback only |
Unicode text (Ο(Ξ± + Ξ²β±Ό zβ±Ό)) | Yes, but it's just text | Fractions, roots and β collapse | β |
The Unicode route is the one that gets used by default, and it silently destroys anything
non-trivial. \sigma(z) = \frac{1}{1+e^{-z}} becomes Ο(z) = 11 + eβ»αΆ».
Relationship to the pptx skill
This is a companion, not a replacement. The pptx skill (and any python-pptx
workflow) handles decks: layouts, text, tables, images, charts. It has no way to emit a
native equation. pptx-math fills exactly that one gap and nothing else.
Typical division of labour:
pptx skill / python-pptx β build the deck, place the text boxes
pptx-math β every place where math appears
When to use it
Use it whenever math reaches a slide β including a single italic variable in a
sentence. Specifically:
- Equations, math variables (
x, r_A, Ξ²_j), Greek letters, sub/superscripts,
fractions, β, β«, matrices.
- Generating a deck from a paper, PDF, or Markdown. Research slides almost always
carry math, and it is easy to flatten it to Unicode without noticing. Inline variables
inside prose (
p, r_A, r_B, y) count.
- Upgrading an existing deck whose equations were typed as plain text
(
Pr(y = 1) = Ο(Ξ± + Ξ²j zj), rA, Ο).
Do not convert acronyms, labels, or plain numbers β AUC, Elo, Ξwin-rate,
β31%p read worse in math italic.
Install
1. Claude Code plugin (recommended)
Two commands, nothing else to install:
/plugin marketplace add maenjh/pptx-math
/plugin install pptx-math
Update later with /plugin marketplace update pptx-math, remove with
/plugin uninstall pptx-math.
2. One-line script
No plugin system, no Node β copies the skill into ~/.claude/skills/pptx-math:
curl -fsSL https://raw.githubusercontent.com/maenjh/pptx-math/main/install.sh | bash
It backs up any existing install and tells you if python-pptx is missing.
3. Manual
git clone --depth 1 https://github.com/maenjh/pptx-math.git /tmp/pptx-math
cp -R /tmp/pptx-math/skills/pptx-math ~/.claude/skills/
4. As a plain Python module
The converter does not need Claude at all.
git clone https://github.com/maenjh/pptx-math.git
pip install python-pptx # matplotlib only for the image fallback
import sys; sys.path.insert(0, "pptx-math/skills/pptx-math/scripts")
from pptx_math import add_native_equation
Requirements
Python 3.9+ and python-pptx. Everything else is standard library. matplotlib is
optional and only used by add_equation_image().
Once installed, the skill triggers on requests like "put an equation in this PPT",
"build slides from this PDF", or "turn these variables into proper math notation".
Quick start
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx_math import add_native_equation, set_paragraph_segments, shape_census
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[6])
box = slide.shapes.add_textbox(Inches(1), Inches(2), Inches(11), Inches(1.2))
# Standalone equation
add_native_equation(box.text_frame,
r"\Pr(y=1) = \sigma(\alpha + \beta_j \cdot z_j + \gamma \cdot \mathbf{x})",
size=Pt(32), align="center", color="1F3864")
# Several equations, one per line
for eq in [r"\sigma(z) = \frac{1}{1+e^{-z}}",
r"\hat{y} = \mathbf{w}^\top \mathbf{x} + b"]:
add_native_equation(box.text_frame, eq, size=Pt(24), align="center")
prs.save("out.pptx")
Inline variables inside a sentence
The most common real-world case: a body bullet that mentions p, rA, rB, y and should
read π, π_π΄, π_π΅, π¦. set_paragraph_segments() reuses the existing run's font, size,
colour and indentation, so the layout does not shift at all.