# Fractions

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

The mfrac element is used to represent fractions and has the following syntax:

<mfrac> numerator denominator </mfrac>

The mfrac element has four attributes: linethickness, bevelled, numalign, and denomalign.

The linethickness attribute specifies the thickness of the line that separates the numerator and denominator. The default setting of 1 causes the line to be drawn in the standard thickness of lines for the font style being used. A setting of 0 causes the line to be invisible and can be used to represent binomial coefficients, as shown here:

``````<mrow>
<mo>(</mo>
<mfrac linethickness="0">
<mi>n</mi>
<mi>r</mi>
</mfrac>
<mo>)</mo>
</mrow>
``````

When the bevelled attribute is set to false, the numerator is shown above the denominator with a horizontal line between them. When it’s set to true, a slightly raised numerator is shown to the left of a slightly lowered denominator with a diagonal line between them, as shown in the following example:

``````<mrow>
<mfrac bevelled="true">
<mn>1</mn>
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
</mfrac>
</mrow>
``````

The attributes numalign and denomalign specify the horizontal alignment of the numerator and denominator, respectively. They can take values left, right, and center. The default is to be centered, but it may be more appropriate for a very long numerator or denominator that stretches along multiple line to be aligned at left.

In the following example, you can left-align the numerator with the denominator by setting the value of numalign="left":

``````<mfrac numalign="left">
<mrow>
<mi>a</mi><mo>+</mo><mi>b</mi>
</mrow>
<mrow>
<mi>a</mi><mo>+</mo><mi>b</mi><mo>+</mo><mi>c</mi>
</mrow>
</mfrac>
``````

It is conventional for the numerator and denominator to appear in a smaller font when a fraction is displayed as an inline expression; that is, surrounded by text. To satisfy this convention, the mfrac element automatically changes the value of two attributes of the mstyle element: displaystyle and scriptlevel, which are normally inherited from the environment. The mfrac element sets displaystyle to false, or if it was already set to false, it increments scriptlevel by 1, within numerator and denominator. For more details about the displaystyle and scriptlevel attributes, see the description of the mstyle element under Applying styles later in this section.

 Tipp der data2type-Redaktion: Zum Thema MathML bieten wir auch folgende Schulungen zur Vertiefung und professionellen Fortbildung an: