| 1 |
<?xml version='1.0' encoding="UTF-8"?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 3 |
xmlns:m="http://www.w3.org/1998/Math/MathML" |
| 4 |
version='1.0'> |
| 5 |
|
| 6 |
<!-- ====================================================================== --> |
| 7 |
<!-- $Id |
| 8 |
This file is part of the XSLT MathML Library distribution. |
| 9 |
See ./README or http://www.raleigh.ru/MathML/mmltex for |
| 10 |
copyright and other information --> |
| 11 |
<!-- ====================================================================== --> |
| 12 |
|
| 13 |
<!-- 3.3.2 mfrac --> |
| 14 |
<xsl:template match="m:mfrac"> |
| 15 |
<xsl:choose> |
| 16 |
<xsl:when test="@linethickness"> |
| 17 |
<xsl:text>\genfrac{}{}{</xsl:text> |
| 18 |
<xsl:choose> |
| 19 |
<xsl:when test="number(@linethickness)"> |
| 20 |
<xsl:value-of select="@linethickness div 10"/> |
| 21 |
<xsl:text>ex</xsl:text> |
| 22 |
</xsl:when> |
| 23 |
<xsl:when test="@linethickness='0'"> |
| 24 |
<xsl:text>0ex</xsl:text> |
| 25 |
</xsl:when> |
| 26 |
<xsl:when test="@linethickness='thin'"> |
| 27 |
<xsl:text>.05ex</xsl:text> |
| 28 |
</xsl:when> |
| 29 |
<xsl:when test="@linethickness='medium'"/> |
| 30 |
<xsl:when test="@linethickness='thick'"> |
| 31 |
<xsl:text>.2ex</xsl:text> |
| 32 |
</xsl:when> |
| 33 |
<xsl:otherwise> |
| 34 |
<xsl:value-of select="@linethickness"/> |
| 35 |
</xsl:otherwise> |
| 36 |
</xsl:choose> |
| 37 |
<xsl:text>}{}{</xsl:text> |
| 38 |
</xsl:when> |
| 39 |
<xsl:otherwise> |
| 40 |
<xsl:text>\frac{</xsl:text> |
| 41 |
</xsl:otherwise> |
| 42 |
</xsl:choose> |
| 43 |
<xsl:if test="@numalign='right'"> |
| 44 |
<xsl:text>\hfill </xsl:text> |
| 45 |
</xsl:if> |
| 46 |
<xsl:apply-templates select="./*[1]"/> |
| 47 |
<xsl:if test="@numalign='left'"> |
| 48 |
<xsl:text>\hfill </xsl:text> |
| 49 |
</xsl:if> |
| 50 |
<xsl:text>}{</xsl:text> |
| 51 |
<xsl:if test="@denomalign='right'"> |
| 52 |
<xsl:text>\hfill </xsl:text> |
| 53 |
</xsl:if> |
| 54 |
<xsl:apply-templates select="./*[2]"/> |
| 55 |
<xsl:if test="@denomalign='left'"> |
| 56 |
<xsl:text>\hfill </xsl:text> |
| 57 |
</xsl:if> |
| 58 |
<xsl:text>}</xsl:text> |
| 59 |
</xsl:template> |
| 60 |
|
| 61 |
<xsl:template match="m:mfrac[@bevelled='true']"> |
| 62 |
<xsl:text>\raisebox{1ex}{$</xsl:text> |
| 63 |
<xsl:apply-templates select="./*[1]"/> |
| 64 |
<xsl:text>$}\!\left/ \!\raisebox{-1ex}{$</xsl:text> |
| 65 |
<xsl:apply-templates select="./*[2]"/> |
| 66 |
<xsl:text>$}\right.</xsl:text> |
| 67 |
</xsl:template> |
| 68 |
|
| 69 |
|
| 70 |
<xsl:template match="m:mroot"> |
| 71 |
<xsl:choose> |
| 72 |
<xsl:when test="count(./*)=2"> |
| 73 |
<xsl:text>\sqrt[</xsl:text> |
| 74 |
<xsl:apply-templates select="./*[2]"/> |
| 75 |
<xsl:text>]{</xsl:text> |
| 76 |
<xsl:apply-templates select="./*[1]"/> |
| 77 |
<xsl:text>}</xsl:text> |
| 78 |
</xsl:when> |
| 79 |
<xsl:otherwise> |
| 80 |
<!-- number of argumnets is not 2 - code 25 --> |
| 81 |
<xsl:message>exception 25:</xsl:message> |
| 82 |
<xsl:text>\text{exception 25:}</xsl:text> |
| 83 |
</xsl:otherwise> |
| 84 |
</xsl:choose> |
| 85 |
</xsl:template> |
| 86 |
|
| 87 |
<xsl:template match="m:msqrt"> |
| 88 |
<xsl:text>\sqrt{</xsl:text> |
| 89 |
<xsl:apply-templates/> |
| 90 |
<xsl:text>}</xsl:text> |
| 91 |
</xsl:template> |
| 92 |
|
| 93 |
<xsl:template match="m:mfenced"> |
| 94 |
<xsl:choose> |
| 95 |
<xsl:when test="@open"> |
| 96 |
<xsl:if test="translate(@open,'{}[]()|','{{{{{{{')='{'"> |
| 97 |
<xsl:text>\left</xsl:text> |
| 98 |
</xsl:if> |
| 99 |
<xsl:if test="@open='{' or @open='}'"> |
| 100 |
<xsl:text>\</xsl:text> |
| 101 |
</xsl:if> |
| 102 |
<xsl:if test="translate(@open,'{}[]()|','{{{{{{{')!='{' and (translate(@close,'{}[]()|','{{{{{{{')='{' or not(@close))"> |
| 103 |
<xsl:text>\left.</xsl:text> |
| 104 |
</xsl:if> |
| 105 |
<xsl:value-of select="@open"/> |
| 106 |
</xsl:when> |
| 107 |
<xsl:otherwise><xsl:text>\left(</xsl:text></xsl:otherwise> |
| 108 |
</xsl:choose> |
| 109 |
<xsl:variable name="sep"> |
| 110 |
<xsl:choose> |
| 111 |
<xsl:when test="@separators"> |
| 112 |
<xsl:value-of select="translate(@separators,' ','')"/> |
| 113 |
</xsl:when> |
| 114 |
<xsl:otherwise>,</xsl:otherwise> |
| 115 |
</xsl:choose> |
| 116 |
</xsl:variable> |
| 117 |
<xsl:for-each select="./*"> |
| 118 |
<xsl:apply-templates select="."/> |
| 119 |
<xsl:if test="not(position()=last())"> |
| 120 |
<xsl:choose> |
| 121 |
<xsl:when test="position()>string-length($sep)"> |
| 122 |
<xsl:value-of select="substring($sep,string-length($sep))"/> |
| 123 |
</xsl:when> |
| 124 |
<xsl:otherwise> |
| 125 |
<xsl:value-of select="substring($sep,position(),1)"/> |
| 126 |
</xsl:otherwise> |
| 127 |
</xsl:choose> |
| 128 |
</xsl:if> |
| 129 |
</xsl:for-each> |
| 130 |
<xsl:choose> |
| 131 |
<xsl:when test="@close"> |
| 132 |
<xsl:if test="translate(@close,'{}[]()|','{{{{{{{')='{'"> |
| 133 |
<xsl:text>\right</xsl:text> |
| 134 |
</xsl:if> |
| 135 |
<xsl:if test="@close='{' or @close='}'"> |
| 136 |
<xsl:text>\</xsl:text> |
| 137 |
</xsl:if> |
| 138 |
<xsl:if test="translate(@close,'{}[]()|','{{{{{{{')!='{' and (translate(@open,'{}[]()|','{{{{{{{')='{' or not(@open))"> |
| 139 |
<xsl:text>\right.</xsl:text> |
| 140 |
</xsl:if> |
| 141 |
<xsl:value-of select="@close"/> |
| 142 |
</xsl:when> |
| 143 |
<xsl:otherwise><xsl:text>\right)</xsl:text></xsl:otherwise> |
| 144 |
</xsl:choose> |
| 145 |
</xsl:template> |
| 146 |
|
| 147 |
<xsl:template match="m:mphantom"> |
| 148 |
<xsl:text>\phantom{</xsl:text> |
| 149 |
<xsl:apply-templates/> |
| 150 |
<xsl:text>}</xsl:text> |
| 151 |
</xsl:template> |
| 152 |
|
| 153 |
<xsl:template match="m:menclose"> |
| 154 |
<xsl:choose> |
| 155 |
<xsl:when test="@notation = 'actuarial'"> |
| 156 |
<xsl:text>\overline{</xsl:text> |
| 157 |
<xsl:apply-templates/> |
| 158 |
<xsl:text>\hspace{.2em}|}</xsl:text> |
| 159 |
</xsl:when> |
| 160 |
<xsl:when test="@notation = 'radical'"> |
| 161 |
<xsl:text>\sqrt{</xsl:text> |
| 162 |
<xsl:apply-templates/> |
| 163 |
<xsl:text>}</xsl:text> |
| 164 |
</xsl:when> |
| 165 |
<xsl:otherwise> |
| 166 |
<xsl:text>\overline{)</xsl:text> |
| 167 |
<xsl:apply-templates/> |
| 168 |
<xsl:text>}</xsl:text> |
| 169 |
</xsl:otherwise> |
| 170 |
</xsl:choose> |
| 171 |
</xsl:template> |
| 172 |
|
| 173 |
<xsl:template match="m:mrow"> |
| 174 |
<xsl:apply-templates/> |
| 175 |
</xsl:template> |
| 176 |
|
| 177 |
<xsl:template match="m:mstyle"> |
| 178 |
<xsl:if test="@displaystyle='true'"> |
| 179 |
<xsl:text>{\displaystyle </xsl:text> |
| 180 |
</xsl:if> |
| 181 |
<xsl:if test="@scriptlevel and not(@displaystyle='true')"> |
| 182 |
<xsl:text>{</xsl:text> |
| 183 |
<xsl:choose> |
| 184 |
<xsl:when test="@scriptlevel=0"><xsl:text>\textstyle </xsl:text></xsl:when> |
| 185 |
<xsl:when test="@scriptlevel=1"><xsl:text>\scriptstyle </xsl:text></xsl:when> |
| 186 |
<xsl:otherwise><xsl:text>\scriptscriptstyle </xsl:text></xsl:otherwise> |
| 187 |
</xsl:choose> |
| 188 |
</xsl:if> |
| 189 |
<xsl:if test="@background"> |
| 190 |
<xsl:text>\colorbox[rgb]{</xsl:text> |
| 191 |
<xsl:call-template name="color"> |
| 192 |
<xsl:with-param name="color" select="@background"/> |
| 193 |
</xsl:call-template> |
| 194 |
<xsl:text>}{$</xsl:text> |
| 195 |
</xsl:if> |
| 196 |
<xsl:if test="@color[not(@mathcolor)] or @mathcolor"> |
| 197 |
<xsl:text>\textcolor[rgb]{</xsl:text> |
| 198 |
<xsl:call-template name="color"> |
| 199 |
<xsl:with-param name="color" select="@color|@mathcolor"/> |
| 200 |
</xsl:call-template> |
| 201 |
<xsl:text>}{</xsl:text> |
| 202 |
</xsl:if> |
| 203 |
<xsl:apply-templates/> |
| 204 |
<xsl:if test="@color[not(@mathcolor)] or @mathcolor"> |
| 205 |
<xsl:text>}</xsl:text> |
| 206 |
</xsl:if> |
| 207 |
<xsl:if test="@background"> |
| 208 |
<xsl:text>$}</xsl:text> |
| 209 |
</xsl:if> |
| 210 |
<xsl:if test="@scriptlevel and not(@displaystyle='true')"> |
| 211 |
<xsl:text>}</xsl:text> |
| 212 |
</xsl:if> |
| 213 |
<xsl:if test="@displaystyle='true'"> |
| 214 |
<xsl:text>}</xsl:text> |
| 215 |
</xsl:if> |
| 216 |
</xsl:template> |
| 217 |
|
| 218 |
<xsl:template match="m:merror"> |
| 219 |
<xsl:apply-templates/> |
| 220 |
</xsl:template> |
| 221 |
|
| 222 |
</xsl:stylesheet> |