Name

math:mfrac (in formatting mode) — Formatting a fraction.

Synopsis

<xsl:template match="math:mfrac" mode="formatting">
<xsl:param name="x"/>
<xsl:param name="y"/>
<xsl:param name="baseline" select="0"/>
<xsl:param name="scriptlevel" tunnel="yes"/>
<xsl:param name="displayStyle" tunnel="yes"/>
<xsl:param name="fracWidMarg" tunnel="yes"/>
<xsl:param name="numDenSpace" tunnel="yes"/>
<xsl:param name="fontName" tunnel="yes"/>
  ...
</xsl:template>

Description

It consists of two children: the first is the numerator and the second is the denominator. First, like all other elements, the numerator and the denominator are computed using the corresponding formatting mode template. When calling the template, some parameters have to be modified to follow the specification. If the display style is false, the script level has to be incremented by one, and, if it is true, it has to be set to false.

The width, height and bottom edge Y coordinate of each child is then retrieved to help compute the box representation of the fraction.

After that, mfrac attributes is retrieved:

linethickness

Determines the size of the fraction bar. By default, this value is 1. After retrieving it, the line thickness is computed in pixel using the unitInPx function. A value with no unit determines a multiplication of the thin value, for example the default value is 1, without unit, it means that the fraction bar must have a height of 1 * thin. It is why the thin space literal is computed in pixels before computing the final fraction bar height. This value will be used as default value for the unitInPx function.

numalign

Determines the alignement of the numerator. Values can be center, left or right. The default one is center.

denomalign

Determines the alignement of the denominator. Values can be center, left or right. The default one is center.

A shift value is also computed to place the fraction bar, this value is computed from the baseline. The fraction bar has to be aligned with a minus sign, in the middle of the text. Therefore, the half size of letter x is used.

The box representation is then computed. The width is the maximum between the numerator and the denominator width plus a margin value both on the right and on the left from the global parameters (fracWidMarg). The baseline and the bottom of the box is set.

Finally, the tree is annotated with the box representation and with shift value for the numerator and the denominator:

SHIFTXNUM

Represents an x-axis shifting to place the numerator with respect to the numalign attribute.

SHIFTXDEN

Represents an x-axis shifting to place the denominator with respect to the denomalign attribute.

SHIFTYNUM

Represents a y-axis shifting to place the numerator above the fraction bar to its final position.

SHIFTYDEN

Represents a y-axis shifting to place the denominator under the fraction bar to its final position.

Values to place and draw the fraction bar are also added to the annotated tree: FRAC_BAR_Y is the Y coordinate of the fraction bar and FRAC_BAR_HEIGHT is its size.