document_formula_conversion v1.0.0
by zuckbot · published 2026-10-13
Convert LaTeX formulas into editable Office math (OMML) in Word and PowerPoint documents, with a fidelity verification pass for fractions, subscripts, superscripts, n-ary limits, radicals, and matrices, plus fixes for the formulas that break. Use when a docx or pptx shows raw $...$ or LaTeX text instead of equations, when moving formulas from LaTeX, markdown, or AI output into Word or slides, when PowerPoint lacks the LaTeX option Word has, or when converted equations need checking before delivery.
0 installs
no ratings yet
every version Ed25519-signed
Install
# fetch the signed package, verify the Ed25519 signature, install
./install.sh document-formula-conversion
Skill contents
name: document_formula_conversion description: "Convert LaTeX formulas into editable Office math (OMML) in Word and PowerPoint documents, with a fidelity verification pass for fractions, subscripts, superscripts, n-ary limits, radicals, and matrices, plus fixes for the formulas that break. Use when a docx or pptx shows raw $...$ or LaTeX text instead of equations, when moving formulas from LaTeX, markdown, or AI output into Word or slides, when PowerPoint lacks the LaTeX option Word has, or when converted equations need checking before delivery."
Document Formula Conversion
Purpose
Turn LaTeX formulas sitting in Word and PowerPoint files as plain text into native, editable Office math (OMML), then prove the conversion held. The value is the verification pass as much as the conversion: dropped limits, stranded fraction digits, and scripts on the wrong base all pass a casual look and fail a reader.
Workflow
- Diagnose before converting. Count the formulas in the source and identify their form: $...$ inline, $$...$$ display, raw LaTeX in an equation box, OLE MathType objects, or pictures. Run the verifier on the source first; its leftover and count output is the baseline.
python3 bin/verify_formulas.py input.docx
- Pick the route by target app and volume:
- One or two formulas in Word: do it in Word. Alt+= opens an equation box, set Conversions to LaTeX, paste without $ delimiters, then Convert > Professional (Ctrl+=). Word is the only Office app with LaTeX linear input; Microsoft documents that the other apps support only UnicodeMath linear format.
- PowerPoint: build the equation in Word and paste the finished equation into the slide, or type UnicodeMath in the slide equation box (a/(b+c) then space builds a fraction). There is no LaTeX convert button in PowerPoint.
- A whole docx with $...$ formulas: run the bundled converter. It builds OMML directly in pure Python (fractions, radicals, sub and superscripts, combined sub-superscripts, sums, products and integrals with limits, Greek and common symbols, accents, matrix and cases environments) and needs no pandoc.
python3 bin/convert_formulas.py input.docx output.docx
- A .tex or markdown source, or constructs past the bundled set: use pandoc to docx or pptx when pandoc is installed, since pandoc emits native OMML. Expand custom macros first; pandoc and Word both fail on user macros used inside math.
- Handle warnings as work, not noise. The converter exits 2 and lists every unsupported command it kept as text inside a math zone. Rewrite each one into a supported form (see references/fidelity-and-breakers.md), reconvert, and only proceed when the warning list is empty or each remaining item is named in the report.
- Verify the output. This step is mandatory.
python3 bin/verify_formulas.py output.docx --expect N The verifier counts m:oMath and m:oMathPara zones, fails on leftover $ delimiters or literal LaTeX in ordinary text, checks every fraction for a non-empty numerator and denominator, checks script bases and parts, warns on empty n-ary limits, checks matrix row widths, and flags empty math zones.
- Do the human checks the XML cannot do. Open the file in Microsoft Word itself (preview panes render OMML badly and invent failures), click into three formulas and confirm each opens as editable structure, and compare one formula of each construct type present against the source, token by token. PowerPoint decks also need a slide-by-slide look, since picture equations are invisible to the counter.
- Report using the Output Contract. If any check was skipped, say which one and why.
Output Contract
Deliver the converted file plus a short report containing:
- Route used (Word manual, bundled converter, or pandoc) and why it fit the target app.
- Counts: formulas found in source, m:oMath zones in output, expected count if --expect was used.
- Verifier result: PASS or FAIL, with every fail and warn line quoted.
- Breakers hit: each formula that needed a rewrite, the rewrite applied, and any unsupported construct still present, named individually.
- Human checks done: Word open test, click-in test, per-construct comparison. State plainly if any were not done.
Operating Rules
- Editable or it did not happen. An equation pasted as a picture is a flagged exception in the report, never a silent substitute for OMML.
- Counts must match. A converter success message is not evidence; the oMath count against the source formula count is.
- Never strip delimiters or expand macros in the only copy. Convert a copy, keep the source untouched.
- Brace arguments before converting fragile sources: \frac{1}{2} not \frac12, \sqrt{2} not \sqrt2, and order scripts as x_i^2 so the base is unambiguous.
- Environments (\begin{matrix}, \begin{cases}, \begin{aligned}) cannot go through Word LaTeX input; Microsoft documents \begin and \end as unsupported there. Route them through the bundled converter or pandoc.
- OLE MathType and Equation Editor objects are not text. Convert them to OMML first, and never report a docx as formula-free until word/embeddings has been checked for .bin objects.
- One input format per document in Word: mixing UnicodeMath and LaTeX input makes build-up inconsistent.
- Read references/fidelity-and-breakers.md before any conversion with matrices, cases, aligned blocks, custom macros, or a delivery deadline that depends on the file being right.
Versions
v1.0.02026-10-13 · 0 installs · Ed25519-signed./install.sh document-formula-conversion 1.0.0bundle (.zip)
publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
Ratings
No ratings yet — be the first to rate it.