# FieldEQ Class

Implements the EQ field.
Inheritance Hierarchy

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
Syntax
public class FieldEQ : Field

The FieldEQ type exposes the following members.

Constructors
NameDescription
FieldEQ
Initializes a new instance of the FieldEQ class
Properties
NameDescription
DisplayResult
Gets the text that represents the displayed field result.
(Inherited from Field.)
End
Gets the node that represents the field end.
(Inherited from Field.)
Format
(Inherited from Field.)
IsDirty
Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
(Inherited from Field.)
IsLocked
Gets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field.)
LocaleId
Gets or sets the LCID of the field.
(Inherited from Field.)
Result
Gets or sets text that is between the field separator and field end.
(Inherited from Field.)
Separator
Gets the node that represents the field separator. Can be null.
(Inherited from Field.)
Start
Gets the node that represents the start of the field.
(Inherited from Field.)
Type
Gets the Microsoft Word field type.
(Inherited from Field.)
Methods
NameDescription
Equals (Inherited from Object.)
Finalize (Inherited from Object.)
GetFieldCode
Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included.
(Inherited from Field.)
GetFieldCode(Boolean)
Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field.)
GetHashCode (Inherited from Object.)
GetType (Inherited from Object.)
MemberwiseClone (Inherited from Object.)
NeedStoreOldResultNodes (Inherited from Field.)
Remove
Removes the field from the document. Returns a node right after the field. If the field's end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null.
(Inherited from Field.)
ToString (Inherited from Object.)
(Inherited from Field.)
Update
Performs the field update. Throws if the field is being updated already.
(Inherited from Field.)
Update(Boolean)
Performs a field update. Throws if the field is being updated already.
(Inherited from Field.)
Examples
Shows how to use the EQ field to display a variety of mathematical equations.
public void FieldEQ()
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// An EQ field displays a mathematical equation consisting of one or many elements
// Each element takes the following form: [switch][options][arguments]
// One switch, several possible options, followed by a set of argument values inside round braces

// Here we use a document builder to insert an EQ field, with an "\f" switch, which corresponds to "Fraction"
// No options are invoked, and the values 1 and 4 are passed as arguments
// This field will display a fraction with 1 as the numerator and 4 as the denominator
FieldEQ field = InsertFieldEq(builder, @"\f(1,4)");

Assert.AreEqual(@" EQ \f(1,4)", field.GetFieldCode());

// One EQ field may contain multiple elements placed sequentially,
// and elements may also be nested by being placed inside the argument brackets of other elements
// The full list of switches and their corresponding options can be found here:
// https://blogs.msdn.microsoft.com/murrays/2018/01/23/microsoft-word-eq-field/

// Array switch "\a", aligned left, 2 columns, 3 points of horizontal and vertical spacing
InsertFieldEq(builder, @"\a \al \co2 \vs3 \hs3(4x,- 4y,-4x,+ y)");

// Bracket switch "\b", bracket character "[", to enclose the contents in a set of square braces
// Note that we are nesting an array inside the brackets, which will altogether look like a matrix in the output
InsertFieldEq(builder, @"\b \bc\[ (\a \al \co3 \vs3 \hs3(1,0,0,0,1,0,0,0,1))");

// Displacement switch "\d", displacing text "B" 30 spaces to the right of "A", displaying the gap as an underline
InsertFieldEq(builder, @"A \d \fo30 \li() B");

// Formula consisting of multiple fractions
InsertFieldEq(builder, @"\f(d,dx)(u + v) = \f(du,dx) + \f(dv,dx)");

// Integral switch "\i", with a summation symbol
InsertFieldEq(builder, @"\i \su(n=1,5,n)");

// List switch "\l"
InsertFieldEq(builder, @"\l(1,1,2,3,n,8,13)");

// Radical switch "\r", displaying a cubed root of x
InsertFieldEq(builder, @"\r (3,x)");

// Subscript/superscript switch "/s", first as a superscript and then as a subscript
InsertFieldEq(builder, @"\s \up8(Superscript) Text \s \do8(Subscript)");

// Box switch "\x", with lines at the top, bottom, left and right of the input
InsertFieldEq(builder, @"\x \to \bo \le \ri(5)");

// More complex combinations
InsertFieldEq(builder, @"\a \ac \vs1 \co1(lim,n→∞) \b (\f(n,n2 + 12) + \f(n,n2 + 22) + ... + \f(n,n2 + n2))");
InsertFieldEq(builder, @"\i (,,  \b(\f(x,x2 + 3x + 2))) \s \up10(2)");
InsertFieldEq(builder, @"\i \in( tan x, \s \up2(sec x), \b(\r(3) )\s \up4(t) \s \up7(2)  dt)");

doc.Save(ArtifactsDir + "Field.EQ.docx");
}

/// <summary>
/// Use a document builder to insert an EQ field, set its arguments and start a new paragraph.
/// </summary>
private static FieldEQ InsertFieldEq(DocumentBuilder builder, string args)
{
FieldEQ field = (FieldEQ)builder.InsertField(FieldType.FieldEquation, true);
builder.MoveTo(field.Separator);
builder.Write(args);
builder.MoveTo(field.Start.ParentNode);

builder.InsertParagraph();
return field;
}