OfficeMath class

Represents an Office Math object such as function, equation, matrix or alike. Can contain child elements including runs of mathematical text, bookmarks, comments, other OfficeMath instances and some other nodes.

public class OfficeMath : CompositeNode


Name Description
ChildNodes { get; } Gets all immediate child nodes of this node.
Count { get; } Gets the number of immediate children of this node.
CustomNodeId { get; set; } Specifies custom node identifier.
DisplayType { get; set; } Gets/sets Office Math display format type which represents whether an equation is displayed inline with the text or displayed on its own line.
virtual Document { get; } Gets the document to which this node belongs.
EquationXmlEncoding { get; set; } Gets/sets an encoding that was used to encode equation XML, if this office math object is read from equation XML. We use the encoding on saving a document to write in same encoding that it was read.
FirstChild { get; } Gets the first child of the node.
HasChildNodes { get; } Returns true if this node has any child nodes.
override IsComposite { get; } Returns true as this node can have child nodes.
Justification { get; set; } Gets/sets Office Math justification.
LastChild { get; } Gets the last child of the node.
MathObjectType { get; } Gets type MathObjectType of this Office Math object.
NextSibling { get; } Gets the node immediately following this node.
override NodeType { get; } Returns NodeType.OfficeMath.
ParentNode { get; } Gets the immediate parent of this node.
ParentParagraph { get; } Retrieves the parent Paragraph of this node.
PreviousSibling { get; } Gets the node immediately preceding this node.
Range { get; } Returns a Range object that represents the portion of a document that is contained in this node.


Name Description
override Accept(DocumentVisitor) Accepts a visitor.
AppendChild(Node) Adds the specified node to the end of the list of child nodes for this node.
Clone(bool) Creates a duplicate of the node.
CreateNavigator() Reserved for system use. IXPathNavigable.
GetAncestor(NodeType) Gets the first ancestor of the specified NodeType.
GetAncestor(Type) Gets the first ancestor of the specified object type.
GetChild(NodeType, int, bool) Returns an Nth child node that matches the specified type.
GetChildNodes(NodeType, bool) Returns a live collection of child nodes that match the specified type.
GetEnumerator() Provides support for the for each style iteration over the child nodes of this node.
GetMathRenderer() Creates and returns an object that can be used to render this equation into an image.
override GetText() Gets the text of this node and of all its children.
IndexOf(Node) Returns the index of the specified child node in the child node array.
InsertAfter(Node, Node) Inserts the specified node immediately after the specified reference node.
InsertBefore(Node, Node) Inserts the specified node immediately before the specified reference node.
NextPreOrder(Node) Gets next node according to the pre-order tree traversal algorithm.
PrependChild(Node) Adds the specified node to the beginning of the list of child nodes for this node.
PreviousPreOrder(Node) Gets the previous node according to the pre-order tree traversal algorithm.
Remove() Removes itself from the parent.
RemoveAllChildren() Removes all the child nodes of the current node.
RemoveChild(Node) Removes the specified child node.
RemoveSmartTags() Removes all SmartTag descendant nodes of the current node.
SelectNodes(string) Selects a list of nodes matching the XPath expression.
SelectSingleNode(string) Selects the first Node that matches the XPath expression.
ToString(SaveFormat) Exports the content of the node into a string in the specified format.
ToString(SaveOptions) Exports the content of the node into a string using the specified save options.


In this version of Aspose.Words, OfficeMath nodes do not provide public methods and properties to create or modify a OfficeMath object. In this version you are not able to instantiate Math nodes or modify existing except deleting them.

OfficeMath can only be a child of Paragraph.


Shows how to set office math display formatting.

Document doc = new Document(MyDir + "Office math.docx");

OfficeMath officeMath = (OfficeMath) doc.GetChild(NodeType.OfficeMath, 0, true);

// OfficeMath nodes that are children of other OfficeMath nodes are always inline.
// The node we are working with is the base node to change its location and display type.
Assert.AreEqual(MathObjectType.OMathPara, officeMath.MathObjectType);
Assert.AreEqual(NodeType.OfficeMath, officeMath.NodeType);
Assert.AreEqual(officeMath.ParentNode, officeMath.ParentParagraph);

// OOXML and WML formats use the "EquationXmlEncoding" property.

// Change the location and display type of the OfficeMath node.
officeMath.DisplayType = OfficeMathDisplayType.Display;
officeMath.Justification = OfficeMathJustification.Left;

doc.Save(ArtifactsDir + "Shape.OfficeMath.docx");

See Also