math:math|math:mrow|math:merror|math:mphantom|math:menclose|math:mstyle (in formatting mode) — Formatting a box element.
<xsl:template match="math:math|math:mrow|math:merror|math:mphantom|math:menclose|math:mstyle" mode="formatting"> <xsl:param name="x"/> <xsl:param name="y"/> <xsl:param name="baseline" select="0"/> <xsl:param name="errorMargin" tunnel="yes"/> <xsl:param name="sizeMult" tunnel="yes"/> <xsl:param name="scriptlevel" tunnel="yes"/> <xsl:param name="displayStyle" tunnel="yes"/> <xsl:param name="mathvariant" tunnel="yes"/> <xsl:param name="mathcolor" tunnel="yes"/> <xsl:param name="mathbackground" tunnel="yes"/> <xsl:param name="veryverythinmathspace" tunnel="yes"/> <xsl:param name="verythinmathspace" tunnel="yes"/> <xsl:param name="thinmathspace" tunnel="yes"/> <xsl:param name="mediummathspace" tunnel="yes"/> <xsl:param name="thickmathspace" tunnel="yes"/> <xsl:param name="verythickmathspace" tunnel="yes"/> <xsl:param name="veryverythickmathspace" tunnel="yes"/> ... </xsl:template>
All these elements are considered to have the same grouping comportment. Therefore, they are all handled the same way in the same template with some exception in the code.
First of all, we retrieve the number of children of the element. If this number is zero, an empty box is created and the
tree is annotated with that box. If the number of children is greater than zero, the element will be treated normally.
This distinction is used to handle correctly empty mrow
that is used frequently.
As usual, all attributes are first retrieved. The notations
menclose
attribute is
retrieved and all multiple spaces are replaced by one space. This attribute is used to determine which element(s) will enclose
the row. It can contain more than one notation. For example, a row can be enclosed by both a circle and a box. After that,
common style attributes are retrieved (there are not all implemented yet) and finally mstyle
attributes are retrieved (in reality, only scriptlevel
is retrieved here because it needs more complex
treatment than others). The currently supported attributes are:
scriptlevel
Modifies the current level of the font size.
displaystyle
Modifies the rendering of some elements.
Space literals (mediummathspace, etc.)
Modify the size value of space literals.
scriptsizemultiplier
Modifies the sizeMult
factor.
mstyle
attributes are quite different from other attributes because they have to be transmitted to their children.
Therefore, they are retrieved when the child templates are called and only when the current element is an mstyle
tag. Before formatting all children, new values for X
and Y
are computed. These new values will help
to add more spaces around the children because menclose
and merror
need them to add elements (boxes,
circle, root sign, etc.).
After that, children are computed using a template that will align them on the same baseline:
subMrow
. It takes four arguments: the new computed X
and Y
values,
the baseline and all the child elements. This template will also correct the operator that has to stretch vertically by calling
appropriate templates. After that, the highest right box side
of children are retrieved to compute the width of the box. The height and Y
information is computed by
retrieving the lowest top side box and the highest bottom side box of children. A shift value is also computed if the children
are getting out of the canvas. For example, if the baseline is at 20 and if a child has a height of 40, it will go out of the
canvas by 20. Therefore, all the children have to be shifted to be drawn correctly on the canevas. After that, the baseline
for this box is computed by using the shift value and the lowest baseline of all children.
Finally, the tree is annotated with box information, with the shift value, with value from its operator child
(EMBELLISH
, LSPACE
, RSPACE
, stretchVertical
and ACCENT
) if the row is considered as an embellished operator
and NOTATION
attribute for menclose
element.