addMathEquation

addMathEquation

TRIAL / ADVANCED / PREMIUM

Inserts a math equation in OMML or MathML format.

Description
public addMathEquation ( string $equation, string $type [, array $options] )

Adds a math equation to the DOCX.

Adding encoded HTML in a MathML equation may require using html_entity_decode with the equation parameter.

LibreOffice and other DOCX readers may have limited support when applying styles.

Parameters

equation

The OMML equation code.

type

The equation type: docx, omml or mathml.

options

The possible keys and values are (required options are shown with yellow background):

Key Type Description
align string left, center, right
bold bool
color string ffffff, ff0000...
fontSize int 8, 9, 10...
italic bool
underline string single...
Code samples

Example #1

The resulting Word document looks like:

Release notes
  • phpdocx 15.5:
    • replace " " with blank spaces.
  • phpdocx 10.0:
    • bold, color, fontSize and italic styles.
  • phpdocx 7.5:
    • align style.
  • phpdocx 5.5:
    • supported as WordFragment.