math
math
¶
The Math proxy, giving access to the equations in a document.
Math
¶
Math(oMath: CT_OMath, parent: ProvidesStoryPart)
Bases: StoryChild
Proxy for an m:oMath element, one equation.
Reached through Paragraph.math or Document.math.
Word stores equations in OMML, a notation of its own with no overlap with the wordprocessing run content. This exposes the equation's XML and the characters in it; it deliberately does not model the notation, which would be a substantially larger piece of work with nothing to render the result.
Source code in src/docx/math.py
text
property
¶
The characters of this equation, with none of its structure.
A fraction reads as its numerator followed by its denominator, a superscript as its base followed by its exponent. This is what a plain-text extraction can offer; it is not a rendering of the equation and will not round-trip.
xml
property
¶
The OMML source of this equation.
The reliable representation, and what to hand to anything that understands OMML — an XSLT to MathML, say.
is_display
property
¶
True when this equation is displayed on a line of its own.
Word wraps a display equation in an m:oMathPara; an inline one sits directly
among the runs of its paragraph.
iter_math
¶
iter_math(
element: BaseOxmlElement, parent: ProvidesStoryPart
) -> Iterator[Math]
Generate a Math for each equation under element, in document order.
Both the inline m:oMath and the m:oMath children of a display m:oMathPara are
found, and each is yielded once.
Source code in src/docx/math.py
math_list
¶
math_list(
element: BaseOxmlElement, parent: ProvidesStoryPart
) -> List[Math]