w:oMath (Office Math)
Toggle property in rPr that marks a run as containing Office Math content, applying math-specific formatting.
Parent elements
Description
w:oMath is a toggle property in w:rPr that marks the run as math content. When active, the processor applies math-specific rendering rules (Office Math fonts, math spacing, etc.) to the run’s text, even if the text does not appear inside an <m:oMath> element.
It is defined in ECMA-376 Part 1 §17.3.2.25.
Note: For mathematical equations in modern OOXML documents, use the Office Math Markup Language (OMML) elements in the
m:namespace (e.g.<m:oMath>,<m:r>, etc.) directly.w:oMathinw:rPris a legacy signal that should rarely be authored manually.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:val |
ST_OnOff |
true, false, 1, 0, on, off |
Marks the run as math content. Omit to inherit. |
Examples
<!-- Inline math content using OMML (preferred approach) -->
<m:oMathPara>
<m:oMath>
<m:r>
<m:rPr><m:sty m:val="p"/></m:rPr>
<m:t>E=mc</m:t>
</m:r>
<m:sSup>
<m:e><m:r><m:t>2</m:t></m:r></m:e>
</m:sSup>
</m:oMath>
</m:oMathPara>
<!-- Using w:oMath as a run property flag (legacy) -->
<w:r>
<w:rPr>
<w:oMath/>
</w:rPr>
<w:t>x</w:t>
</w:r>
using DocumentFormat.OpenXml.Wordprocessing;
var run = new Run(
new RunProperties(new OfficeMath()),
new Text("x")
);
Notes
- For full mathematical equation support, use OMML (
m:oMath,m:r, etc.) — notw:oMathinw:rPr. w:oMathinw:rPris typically generated when Word converts between OMML and its internal representation.