To write a fraction, or any thing which should be displayed in a similar way (e.g.: binomial coefficients), we can use the <mfrac> element.
|
|
The fraction is our first example of a feature which is strange to XML but common to MathML: the importance of order. Within an <mfrac> the first child is defined as the numerator and the second child the denominator. This also means that it must have exactly two children, no more, no less. When either the numerator or denominator are expressions in their own right, they must be grouped together in some other tag such as the <mrow> in the example above.
There are also four fraction-specific attributes which can be set to describe the layout of the fraction:
| Attribute | Description | Allowed Values |
|---|---|---|
| linethickness | Sets the thickness of the line which separates the numerator and the denominator |
|
| numalign | Sets the alignment of the numerator |
|
| denomalign | Sets the alignment of the numerator |
|
| bevelled | Determines whether the fraction is displayed with the separating line horizontal (false) or at an angle (true) |
|
Here are some examples of their use:
As we said earlier, <mfrac> is not just for fractions. By setting linethickness="0" we can use <mfrac> to display binomial coefficients:
|
|
Using the 'denomalign' attribute, we can align the denominator in this expression to the right of the fraction.
|
|
The same can be done with the numerator using 'numalign'.
When the 'bevelled' attribute is set to 'true', the fraction is displayed with a diagonal separator, instead of the horizontal one in the other examples above.
|
|