Summary: Lay out elements are responsible for two dimensional structure, arrangement and final appearnce by the rendering system.
Note: Your browser may not currently support MathML. See our browser support page for additional details. You can always view the correct math in the PDF version.
Layout elements control two dimensional layout of characters, symbols and composed expressions. There are three groups of elements that determine the two dimensional lay out of the mathematical content and affects its maangement.
Basic layout elements comprises of 10 elements. The names and their basic role in rendering layout are listed here :
The “mrow” element is a horizontal sub-grouping facility. Grouping of sub expression is an important requirement for variety of reasons. Primarily, this element determines the relationship between an “operator” and “operand”. When there is single character “operator” and “operand” relationship, then grouping is not an issue. However, when there more than one “operand” in an expression, then grouping is required.
Grouping of elements is also important where elements require certain numbers of argument. In such situation, it is possible that there are more child elements than the arguments required. Consider the example here, where child elements are grouped to meet the requirement of “mfrac” syntax for two arguments.
<m:math display="block">
<m:mfrac>
<m:mrow>
<m:mi>x</m:mi>
<m:mo>+</m:mo>
<m:mn>y</m:mn>
</m:mrow>
<m:mn>z</m:mn>
</m:mfrac>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
In the example above, “mrow” element is used to group the sub-expression “x + y” to be treated as numerator in “mfrac” implementation.
We have also seen earlier that “mrow” plays important role in determining the form of an operator. The form of an operator as “prefix” or “infix” or “postfix” is determined by the position of an operator in the group of sub expression defined by “mrow” element.
Grouping of elements, terms and sub-expressions (in yet another sub-expression) is a common requirement for meaningful mathematical expression. As such, MathML platform implements an inferred mechanism, whereby certain elements infer that the child elements are grouped with “mrow” in an implicit manner. This means that we may save on writing a pair of “mrow” tags in such situation.
The elements, which implements inferred “mrow” are : “msqrt”, “mstyle”, “merror”, “menclose”, “mpadded”, “mphantom”, “mtd”, and “math”. Important to note here is the inclusion of top level “math” element in the list. It means that putting “mrow” tag just after “math” element is actually redundant.
If we look closely at the elements, which implement inferred “mrow”, then we observe that all these elements require to treat everything inside it as a single unit. This is the reason that they would otherwise require a pair of “mrow” tags to combine all child elements as one group. It is, therefore, good thinking on the part of MathML developers to enforce “mrow” inexplicitly and save on coding and avoid cluttering with “mrow” tags.
The “mfrac” element renders fraction in
<mfrac> numerator denominator </mfrac>
The “mfrac” element is an extremely flexible element to produce very complicated fraction, in which numerator or denominator may themselves be a fraction. Such implementation is affected by nested “mfrac” as shown in the example here.
<m:math display="block">
<m:mi> x </m:mi>
<m:mo> = </m:mo>
<m:mfrac>
<m:mrow>
<m:mn> 1 </m:mn>
<m:mo> + </m:mo>
<m:mfrac>
<m:mn> 3 </m:mn>
<m:mn> 10 </m:mn>
</m:mfrac>
</m:mrow>
<m:mrow>
<m:mfrac>
<m:mn> 2 </m:mn>
<m:mn> 7 </m:mn>
</m:mfrac>
<m:mo> + </m:mo>
<m:mfrac>
<m:mn> 12 </m:mn>
<m:mn> 5 </m:mn>
</m:mfrac>
</m:mrow>
</m:mfrac>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
In the example, the numerator of the outermost “mfrac” element contains expression consisting of another “mfrac” element, while the denominator consists of two “mfrac” elements. Also note the use of “mrow” element to ensure that a “mfrac” elements takes exactly two arguments.
The fraction is displayed with a fraction bar or rule, separating numerator and denominator. Appearance of this bar can be changed using “linethickness” attribute. The default thickness of the bar is set by the rendering enviornment. When set to zero, no bar is shown.
A thicker bar, in relation to default thickness, can be shown assigning values to “linethickness” attribute. MathML provides predetermined thin, medium and thick values, which is a preferred technique to display different thicknesses of the bar. This way, we can maintain uniformity in our display. Normally, bar thickness is not required to be changed except when nested “mfrac” is implemented. In that case, there are more than one bar and as such it may be required to distinguish the central bar from others. The example given here encapsulates these aspects of “mfrac” display. .
<m:math display="block">
<m:mi> x </m:mi>
<m:mo> = </m:mo>
<m:mfrac linethickness="thick">
<m:mrow>
<m:mn> 1 </m:mn>
<m:mo> + </m:mo>
<m:mfrac linethickness="medium">
<m:mn> 3 </m:mn>
<m:mn> 10 </m:mn>
</m:mfrac>
</m:mrow>
<m:mrow>
<m:mfrac>
<m:mn> 2 </m:mn>
<m:mn> 7 </m:mn>
</m:mfrac>
<m:mo> + </m:mo>
<m:mfrac>
<m:mrow>
<m:mfrac linethickness="medium">
<m:mn> 8 </m:mn>
<m:mn> 11 </m:mn>
</m:mfrac>
</m:mrow>
<m:mn> 5 </m:mn>
</m:mfrac>
</m:mrow>
</m:mfrac>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
The “numalign” and “demoalign” affects alignment of numerator and denominator with respect to the bar. In most of the case, we do not change the default “center” element as this is the manner in which expressions are written in mathematics.
The “bevelled” attribute provides an alternate form for rendering fraction. In beveled form, the bar is a slant line, in stead of a horizontal line. This form is useful, when we want to include fraction inside the text as its default form takes more vertical space than that of the text, disturbing line spacing between text lines. More significantly, this reduces vertical space of an intensively nested expression.
<m:math display="block">
<m:mi> x </m:mi>
<m:mo> = </m:mo>
<m:mfrac bevelled="true" linethickness="thick">
<m:mrow>
<m:mn> 1 </m:mn>
<m:mo> + </m:mo>
<m:mfrac linethickness="medium">
<m:mn> 3 </m:mn>
<m:mn> 10 </m:mn>
</m:mfrac>
</m:mrow>
<m:mrow>
<m:mfrac>
<m:mn> 2 </m:mn>
<m:mn> 7 </m:mn>
</m:mfrac>
<m:mo> + </m:mo>
<m:mfrac>
<m:mrow>
<m:mfrac bevelled="true" linethickness="medium">
<m:mn> 8 </m:mn>
<m:mn> 11 </m:mn>
</m:mfrac>
</m:mrow>
<m:mn> 5 </m:mn>
</m:mfrac>
</m:mrow>
</m:mfrac>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
The “msqrt” and “mroot” are radical elements. The “msqrt” element renders square root, while “mroot” element represents indices with a base and index.
The “msqrt” element accepts zero or one argument. Its syntax is :
<msqrt> base </msqrt>
When there are more than one child elements, then they are considered to be enclosed within “mrow” tags. This means that the “msqrt” element draws an inferred implementation of “mrow”. This saves us from coding “mrow” tags explicitly, irrespective of numbers of arguments.
<m:math display="block">
<m:msqrt>
<m:mi>x</m:mi>
<m:mo>-</m:mo>
<m:mn>3</m:mn>
</m:msqrt>
</m:math>
Save the file after editing as “test.xml”. The display looks like :
Like other elements in MathML, “msqrt” element supports nesting to enclose square root recursively.
<m:math display="block">
<m:msqrt>
<m:mi>{</m:mi>
<m:mi>x</m:mi>
<m:mi>+</m:mi>
<m:msqrt>
<m:mi>(</m:mi>
<m:mi>x</m:mi>
<m:mi>+</m:mi>
<m:mi>10</m:mi>
<m:mi>)</m:mi>
</m:msqrt>
<m:mi>}</m:mi>
</m:msqrt> </m:math>
Save the file after editing as “test.xml”. The display looks like :
The “mroot” element requires exactly two arguments – the first one as the base and second as index. The syntax of the element is :
<m:mroot> base index </m:mroot>
Each of these arguments may be combination of elements, which must be grouped separately with the help of “mrow” element in two distinct groups.
<m:math display="block">
<m:mroot>
<m:mrow>
<m:mi>x</m:mi>
<m:mo>-</m:mo>
<m:mn>3</m:mn>
</m:mrow>
<m:mfrac>
<m:mi>x</m:mi>
<m:mn>2</m:mn>
</m:mfrac>
</m:mroot>
</m:math>
Save the file after editing as “test.xml”. The display looks like :