Embed mathematical equations using MathML or AsciiMath notation.

1. MathML Formulas

Pass MathML markup directly to add_math:

para = Uniword::Paragraph.new
para.add_math('<math><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math>')
doc.add_element(para)

Uniword converts MathML to Office Math Markup Language (OMML) using the m: namespace, which is fully supported with 65 modeled elements.

2. AsciiMath Formulas

For a more concise syntax, use AsciiMath notation:

# Add AsciiMath formula (converted to MathML)
para = Uniword::Paragraph.new
para.add_math('x = (-b)/(2a)', format: :asciimath)
doc.add_element(para)

AsciiMath input is automatically converted to MathML internally before being transformed to OMML for the DOCX output.

AsciiMath support depends on the Plurimath gem for the conversion pipeline.