1 <?xml version='1.0' encoding="UTF-8"?>
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:m="http://www.w3.org/1998/Math/MathML"
7 <!-- ====================================================================== -->
8 <!-- $id: tokens.xsl, 2002/22/11 Exp $
9 This file is part of the XSLT MathML Library distribution.
10 See ./README or http://www.raleigh.ru/MathML/mmltex for
11 copyright and other information -->
12 <!-- ====================================================================== -->
15 <xsl:template match="m:cn"><xsl:apply-templates/></xsl:template>
17 <xsl:template match="m:cn[@type='complex-cartesian']">
18 <xsl:apply-templates select="text()[1]"/>
19 <xsl:text>+</xsl:text>
20 <xsl:apply-templates select="text()[2]"/>
21 <xsl:text>i</xsl:text>
24 <xsl:template match="m:cn[@type='rational']">
25 <xsl:apply-templates select="text()[1]"/>
26 <xsl:text>/</xsl:text>
27 <xsl:apply-templates select="text()[2]"/>
30 <xsl:template match="m:cn[@type='integer' and @base!=10]">
31 <xsl:apply-templates/>
32 <xsl:text>_{</xsl:text><xsl:value-of select="@base"/><xsl:text>}</xsl:text>
35 <xsl:template match="m:cn[@type='complex-polar']">
36 <xsl:apply-templates select="text()[1]"/>
37 <xsl:text>e^{i </xsl:text>
38 <xsl:apply-templates select="text()[2]"/>
39 <xsl:text>}</xsl:text>
42 <xsl:template match="m:cn[@type='e-notation']">
43 <xsl:apply-templates select="text()[1]"/>
44 <xsl:text>E</xsl:text>
45 <xsl:apply-templates select="text()[2]"/>
48 <!-- 4.4.1.1 ci 4.4.1.2 csymbol -->
49 <xsl:template match="m:ci | m:csymbol">
51 <xsl:when test="string-length(normalize-space(text()))>1">
52 <xsl:text>\mathrm{</xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text>
54 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
58 <!-- 4.4.2.1 apply 4.4.2.2 reln -->
59 <xsl:template match="m:apply | m:reln">
60 <xsl:apply-templates select="*[1]">
62 <xsl:with-param name="p" select="10"/>
63 </xsl:apply-templates>
65 <xsl:text>(</xsl:text>
66 <xsl:for-each select="*[position()>1]">
67 <xsl:apply-templates select="."/>
68 <xsl:if test="not(position()=last())"><xsl:text>, </xsl:text></xsl:if>
70 <xsl:text>)</xsl:text>
74 <xsl:template match="m:fn[m:apply[1]]"> <!-- for m:fn using default rule -->
75 <xsl:text>(</xsl:text><xsl:apply-templates/><xsl:text>)</xsl:text>
78 <!-- 4.4.2.4 interval -->
79 <xsl:template match="m:interval[*[2]]">
81 <xsl:when test="@closure='open' or @closure='open-closed'">
82 <xsl:text>\left(</xsl:text>
84 <xsl:otherwise><xsl:text>\left[</xsl:text></xsl:otherwise>
86 <xsl:apply-templates select="*[1]"/>
87 <xsl:text> , </xsl:text>
88 <xsl:apply-templates select="*[2]"/>
90 <xsl:when test="@closure='open' or @closure='closed-open'">
91 <xsl:text>\right)</xsl:text>
93 <xsl:otherwise><xsl:text>\right]</xsl:text></xsl:otherwise>
97 <xsl:template match="m:interval">
98 <xsl:text>\left\{</xsl:text><xsl:apply-templates/><xsl:text>\right\}</xsl:text>
101 <!-- 4.4.2.5 inverse -->
102 <xsl:template match="m:apply[*[1][self::m:inverse]]">
103 <xsl:apply-templates select="*[2]"/><xsl:text>^{(-1)}</xsl:text>
106 <!-- 4.4.2.6 sep 4.4.2.7 condition -->
107 <xsl:template match="m:sep | m:condition"><xsl:apply-templates/></xsl:template>
109 <!-- 4.4.2.9 lambda -->
110 <xsl:template match="m:lambda">
111 <xsl:text>\mathrm{lambda}\: </xsl:text>
112 <xsl:apply-templates select="m:bvar/*"/>
113 <xsl:text>.\: </xsl:text>
114 <xsl:apply-templates select="*[last()]"/>
117 <!-- 4.4.2.10 compose -->
118 <xsl:template match="m:apply[*[1][self::m:compose]]">
119 <xsl:param name="p" select="0"/>
120 <xsl:call-template name="infix">
121 <xsl:with-param name="this-p" select="1"/>
122 <xsl:with-param name="p" select="$p"/>
123 <xsl:with-param name="mo">\circ </xsl:with-param>
127 <!-- 4.4.2.11 ident -->
128 <xsl:template match="m:ident"><xsl:text>\mathrm{id}</xsl:text></xsl:template>
130 <!-- 4.4.2.12 domain 4.4.2.13 codomain 4.4.2.14 image 4.4.3.21 arg 4.4.3.24 lcm
131 4.4.5.9 grad 4.4.5.10 curl 4.4.9.4 median 4.4.9.5 mode-->
132 <xsl:template match="m:domain | m:codomain | m:image | m:arg | m:lcm | m:grad |
133 m:curl | m:median | m:mode">
134 <xsl:text>\mathop{\mathrm{</xsl:text>
135 <xsl:value-of select="local-name()"/>
136 <xsl:text>}}</xsl:text>
139 <!-- 4.4.2.15 domainofapplication -->
140 <xsl:template match="m:domainofapplication"/>
142 <!-- 4.4.2.16 piecewise -->
143 <xsl:template match="m:piecewise">
144 <xsl:text>\begin{cases}</xsl:text>
145 <xsl:apply-templates select="m:piece"/>
146 <xsl:apply-templates select="m:otherwise"/>
147 <xsl:text>\end{cases}</xsl:text>
150 <xsl:template match="m:piece">
151 <xsl:apply-templates select="*[1]"/>
152 <xsl:text> & \text{if $</xsl:text>
153 <xsl:apply-templates select="*[2]"/>
154 <xsl:text>$}</xsl:text>
155 <xsl:if test="not(position()=last()) or ../m:otherwise"><xsl:text>\\ </xsl:text></xsl:if>
158 <xsl:template match="m:otherwise">
159 <xsl:apply-templates select="*[1]"/>
160 <xsl:text> & \text{otherwise}</xsl:text>
163 <!-- 4.4.3.1 quotient -->
164 <xsl:template match="m:apply[*[1][self::m:quotient]]">
165 <xsl:text>\left\lfloor\frac{</xsl:text>
166 <xsl:apply-templates select="*[2]"/>
167 <xsl:text>}{</xsl:text>
168 <xsl:apply-templates select="*[3]"/>
169 <xsl:text>}\right\rfloor </xsl:text>
172 <!-- 4.4.3.2 factorial -->
173 <xsl:template match="m:apply[*[1][self::m:factorial]]">
174 <xsl:apply-templates select="*[2]">
175 <xsl:with-param name="p" select="7"/>
176 </xsl:apply-templates>
177 <xsl:text>!</xsl:text>
180 <!-- 4.4.3.3 divide -->
181 <xsl:template match="m:apply[*[1][self::m:divide]]">
182 <xsl:param name="p" select="0"/>
183 <xsl:param name="this-p" select="3"/>
184 <xsl:if test="$this-p < $p"><xsl:text>\left(</xsl:text></xsl:if>
185 <xsl:text>\frac{</xsl:text>
186 <xsl:apply-templates select="*[2]"/>
187 <!-- <xsl:with-param name="p" select="$this-p"/>
188 </xsl:apply-templates>-->
189 <xsl:text>}{</xsl:text>
190 <xsl:apply-templates select="*[3]"/>
191 <!-- <xsl:with-param name="p" select="$this-p"/>
192 </xsl:apply-templates>-->
193 <xsl:text>}</xsl:text>
194 <xsl:if test="$this-p < $p"><xsl:text>\right)</xsl:text></xsl:if>
197 <!-- 4.4.3.4 max min -->
198 <xsl:template match="m:apply[*[1][self::m:max or self::m:min]]">
199 <xsl:text>\</xsl:text>
200 <xsl:value-of select="local-name(*[1])"/>
201 <xsl:text>\{</xsl:text>
203 <xsl:when test="m:condition">
204 <xsl:apply-templates select="*[last()]"/>
205 <xsl:text>, </xsl:text>
206 <xsl:apply-templates select="m:condition/node()"/>
209 <xsl:for-each select="*[position() > 1]">
210 <xsl:apply-templates select="."/>
211 <xsl:if test="position() !=last()"><xsl:text> , </xsl:text></xsl:if>
215 <xsl:text>\}</xsl:text>
218 <!-- 4.4.3.5 minus-->
219 <xsl:template match="m:apply[*[1][self::m:minus] and count(*)=2]">
220 <xsl:text>-</xsl:text>
221 <xsl:apply-templates select="*[2]">
222 <xsl:with-param name="p" select="5"/>
223 </xsl:apply-templates>
226 <xsl:template match="m:apply[*[1][self::m:minus] and count(*)>2]">
227 <xsl:param name="p" select="0"/>
228 <xsl:call-template name="binary">
229 <xsl:with-param name="mo">-</xsl:with-param>
230 <xsl:with-param name="p" select="$p"/>
231 <xsl:with-param name="this-p" select="2"/>
236 <xsl:template match="m:apply[*[1][self::m:plus]]">
237 <xsl:param name="p" select="0"/>
238 <xsl:if test="$p > 2">
239 <xsl:text>(</xsl:text>
241 <xsl:for-each select="*[position()>1]">
242 <xsl:if test="position() > 1">
244 <xsl:when test="self::m:apply[*[1][self::m:times] and
245 *[2][self::m:apply/*[1][self::m:minus] or self::m:cn[not(m:sep) and
246 (number(.) < 0)]]]">-</xsl:when>
247 <xsl:otherwise>+</xsl:otherwise>
251 <xsl:when test="self::m:apply[*[1][self::m:times] and
252 *[2][self::m:cn[not(m:sep) and (number(.) <0)]]]">
253 <xsl:value-of select="-(*[2])"/>
254 <xsl:apply-templates select=".">
255 <xsl:with-param name="first" select="2"/>
256 <xsl:with-param name="p" select="2"/>
257 </xsl:apply-templates>
259 <xsl:when test="self::m:apply[*[1][self::m:times] and
260 *[2][self::m:apply/*[1][self::m:minus]]]">
261 <xsl:apply-templates select="./*[2]/*[2]"/>
262 <xsl:apply-templates select=".">
263 <xsl:with-param name="first" select="2"/>
264 <xsl:with-param name="p" select="2"/>
265 </xsl:apply-templates>
268 <xsl:apply-templates select=".">
269 <xsl:with-param name="p" select="2"/>
270 </xsl:apply-templates>
274 <xsl:if test="$p > 2">
275 <xsl:text>)</xsl:text>
279 <!-- 4.4.3.7 power -->
280 <xsl:template match="m:apply[*[1][self::m:power]]">
281 <xsl:apply-templates select="*[2]">
282 <xsl:with-param name="p" select="5"/>
283 </xsl:apply-templates>
284 <xsl:text>^{</xsl:text>
285 <xsl:apply-templates select="*[3]">
286 <xsl:with-param name="p" select="5"/>
287 </xsl:apply-templates>
288 <xsl:text>}</xsl:text>
291 <!-- 4.4.3.8 remainder -->
292 <xsl:template match="m:apply[*[1][self::m:rem]]">
293 <xsl:param name="p" select="0"/>
294 <xsl:call-template name="binary">
295 <xsl:with-param name="mo">\mod </xsl:with-param>
296 <xsl:with-param name="p" select="$p"/>
297 <xsl:with-param name="this-p" select="3"/>
301 <!-- 4.4.3.9 times-->
302 <xsl:template match="m:apply[*[1][self::m:times]]" name="times">
303 <xsl:param name="p" select="0"/>
304 <xsl:param name="first" select="1"/>
305 <xsl:if test="$p > 3"><xsl:text>(</xsl:text></xsl:if>
306 <xsl:for-each select="*[position()>1]">
307 <xsl:if test="position() > 1">
309 <xsl:when test="self::m:cn">\times <!-- times --></xsl:when>
310 <xsl:otherwise><!--invisible times--></xsl:otherwise>
313 <xsl:if test="position()>= $first">
314 <xsl:apply-templates select=".">
315 <xsl:with-param name="p" select="3"/>
316 </xsl:apply-templates>
319 <xsl:if test="$p > 3"><xsl:text>)</xsl:text></xsl:if>
322 <!-- 4.4.3.10 root -->
323 <xsl:template match="m:apply[*[1][self::m:root]]">
324 <xsl:text>\sqrt</xsl:text>
325 <xsl:if test="m:degree!=2">
326 <xsl:text>[</xsl:text>
327 <xsl:apply-templates select="m:degree/*"/>
328 <xsl:text>]</xsl:text>
330 <xsl:text>{</xsl:text>
331 <xsl:apply-templates select="*[position()>1 and not(self::m:degree)]"/>
332 <xsl:text>}</xsl:text>
335 <!-- 4.4.3.11 gcd -->
336 <xsl:template match="m:gcd"><xsl:text>\gcd </xsl:text></xsl:template>
338 <!-- 4.4.3.12 and -->
339 <xsl:template match="m:apply[*[1][self::m:and]]">
340 <xsl:param name="p" select="0"/>
341 <xsl:call-template name="infix">
342 <xsl:with-param name="this-p" select="2"/>
343 <xsl:with-param name="p" select="$p"/>
344 <xsl:with-param name="mo">\land <!-- and --></xsl:with-param>
349 <xsl:template match="m:apply[*[1][self::m:or]]">
350 <xsl:param name="p" select="0"/>
351 <xsl:call-template name="infix">
352 <xsl:with-param name="this-p" select="3"/>
353 <xsl:with-param name="p" select="$p"/>
354 <xsl:with-param name="mo">\lor </xsl:with-param>
358 <!-- 4.4.3.14 xor -->
359 <xsl:template match="m:apply[*[1][self::m:xor]]">
360 <xsl:param name="p" select="0"/>
361 <xsl:call-template name="infix">
362 <xsl:with-param name="this-p" select="3"/>
363 <xsl:with-param name="p" select="$p"/>
364 <xsl:with-param name="mo">\mathop{\mathrm{xor}}</xsl:with-param>
368 <!-- 4.4.3.15 not -->
369 <xsl:template match="m:apply[*[1][self::m:not]]">
370 <xsl:text>\neg </xsl:text>
371 <xsl:apply-templates select="*[2]">
372 <xsl:with-param name="p" select="7"/>
373 </xsl:apply-templates>
376 <!-- 4.4.3.16 implies -->
377 <xsl:template match="m:apply[*[1][self::m:implies]]">
378 <xsl:param name="p" select="0"/>
379 <xsl:call-template name="binary">
380 <xsl:with-param name="mo">\implies </xsl:with-param>
381 <xsl:with-param name="p" select="$p"/>
382 <xsl:with-param name="this-p" select="3"/>
386 <!-- 4.4.3.17 forall 4.4.3.18 exists -->
387 <xsl:template match="m:apply[*[1][self::m:forall or self::m:exists]]">
388 <xsl:text>\</xsl:text>
389 <xsl:value-of select="local-name(*[1])"/>
390 <xsl:text> </xsl:text>
391 <xsl:apply-templates select="m:bvar"/>
392 <xsl:if test="m:condition">
393 <xsl:text>, </xsl:text><xsl:apply-templates select="m:condition"/>
395 <xsl:if test="*[last()][local-name()!='condition'][local-name()!='bvar']">
396 <xsl:text>\colon </xsl:text>
397 <xsl:apply-templates select="*[last()]"/>
401 <!-- 4.4.3.19 abs -->
402 <xsl:template match="m:apply[*[1][self::m:abs]]">
403 <xsl:text>\left|</xsl:text>
404 <xsl:apply-templates select="*[2]"/>
405 <xsl:text>\right|</xsl:text>
408 <!-- 4.4.3.20 conjugate -->
409 <xsl:template match="m:apply[*[1][self::m:conjugate]]">
410 <xsl:text>\overline{</xsl:text><xsl:apply-templates select="*[2]"/><xsl:text>}</xsl:text>
413 <!-- 4.4.3.22 real -->
414 <xsl:template match="m:real"><xsl:text>\Re </xsl:text></xsl:template>
416 <!-- 4.4.3.23 imaginary -->
417 <xsl:template match="m:imaginary"><xsl:text>\Im </xsl:text></xsl:template>
419 <!-- 4.4.3.25 floor -->
420 <xsl:template match="m:apply[*[1][self::m:floor]]">
421 <xsl:text>\lfloor </xsl:text>
422 <xsl:apply-templates select="*[2]"/>
423 <xsl:text>\rfloor </xsl:text>
426 <!-- 4.4.3.25 ceiling -->
427 <xsl:template match="m:apply[*[1][self::m:ceiling]]">
428 <xsl:text>\lceil </xsl:text>
429 <xsl:apply-templates select="*[2]"/>
430 <xsl:text>\rceil </xsl:text>
434 <xsl:template match="m:apply[*[1][self::m:eq]]">
435 <xsl:param name="p" select="0"/>
436 <xsl:call-template name="infix">
437 <xsl:with-param name="this-p" select="1"/>
438 <xsl:with-param name="p" select="$p"/>
439 <xsl:with-param name="mo">=</xsl:with-param>
444 <xsl:template match="m:apply[*[1][self::m:neq]]">
445 <xsl:param name="p" select="0"/>
446 <xsl:call-template name="infix">
447 <xsl:with-param name="this-p" select="1"/>
448 <xsl:with-param name="p" select="$p"/>
449 <xsl:with-param name="mo">\neq </xsl:with-param>
454 <xsl:template match="m:apply[*[1][self::m:gt]]">
455 <xsl:param name="p" select="0"/>
456 <xsl:call-template name="infix">
457 <xsl:with-param name="this-p" select="1"/>
458 <xsl:with-param name="p" select="$p"/>
459 <xsl:with-param name="mo">> </xsl:with-param>
464 <xsl:template match="m:apply[*[1][self::m:lt]]">
465 <xsl:param name="p" select="0"/>
466 <xsl:call-template name="infix">
467 <xsl:with-param name="this-p" select="1"/>
468 <xsl:with-param name="p" select="$p"/>
469 <xsl:with-param name="mo">< </xsl:with-param>
474 <xsl:template match="m:apply[*[1][self::m:geq]]">
475 <xsl:param name="p" select="0"/>
476 <xsl:call-template name="infix">
477 <xsl:with-param name="this-p" select="1"/>
478 <xsl:with-param name="p" select="$p"/>
479 <xsl:with-param name="mo">\ge </xsl:with-param>
484 <xsl:template match="m:apply[*[1][self::m:leq]]">
485 <xsl:param name="p" select="0"/>
486 <xsl:call-template name="infix">
487 <xsl:with-param name="this-p" select="1"/>
488 <xsl:with-param name="p" select="$p"/>
489 <xsl:with-param name="mo">\le </xsl:with-param>
493 <!-- 4.4.4.7 equivalent -->
494 <xsl:template match="m:apply[*[1][self::m:equivalent]]">
495 <xsl:param name="p" select="0"/>
496 <xsl:call-template name="infix">
497 <xsl:with-param name="this-p" select="1"/>
498 <xsl:with-param name="p" select="$p"/>
499 <xsl:with-param name="mo">\equiv </xsl:with-param>
503 <!-- 4.4.4.8 approx -->
504 <xsl:template match="m:apply[*[1][self::m:approx]]">
505 <xsl:param name="p" select="0"/>
506 <xsl:call-template name="infix">
507 <xsl:with-param name="this-p" select="1"/>
508 <xsl:with-param name="p" select="$p"/>
509 <xsl:with-param name="mo">\approx </xsl:with-param>
513 <!-- 4.4.4.9 factorof -->
514 <xsl:template match="m:apply[*[1][self::m:factorof]]">
515 <xsl:param name="p" select="0"/>
516 <xsl:call-template name="binary">
517 <xsl:with-param name="mo"> | </xsl:with-param>
518 <xsl:with-param name="p" select="$p"/>
519 <xsl:with-param name="this-p" select="3"/>
524 <xsl:template match="m:apply[*[1][self::m:int]]">
525 <xsl:text>\int</xsl:text>
526 <xsl:if test="m:lowlimit/*|m:interval/*[1]|m:condition/*">
527 <xsl:text>_{</xsl:text>
528 <xsl:apply-templates select="m:lowlimit/*|m:interval/*[1]|m:condition/*"/>
529 <xsl:text>}</xsl:text>
531 <xsl:if test="m:uplimit/*|m:interval/*[2]">
532 <xsl:text>^{</xsl:text>
533 <xsl:apply-templates select="m:uplimit/*|m:interval/*[2]"/>
534 <xsl:text>}</xsl:text>
536 <xsl:text> </xsl:text>
537 <xsl:apply-templates select="*[last()]"/>
538 <xsl:text>\,d </xsl:text>
539 <xsl:apply-templates select="m:bvar"/>
542 <!-- 4.4.5.2 diff -->
543 <xsl:template match="m:apply[*[1][self::m:diff] and m:ci and count(*)=2]" priority="2">
544 <xsl:apply-templates select="*[2]"/>
545 <xsl:text>^\prime </xsl:text>
548 <xsl:template match="m:apply[*[1][self::m:diff]]" priority="1">
549 <xsl:text>\frac{</xsl:text>
551 <xsl:when test="m:bvar/m:degree">
552 <xsl:text>d^{</xsl:text>
553 <xsl:apply-templates select="m:bvar/m:degree/node()"/>
554 <xsl:text>}</xsl:text>
555 <xsl:apply-templates select="*[last()]"/>
556 <xsl:text>}{d</xsl:text>
557 <xsl:apply-templates select="m:bvar/node()"/>
558 <xsl:text>^{</xsl:text>
559 <xsl:apply-templates select="m:bvar/m:degree/node()"/>
560 <xsl:text>}</xsl:text>
563 <xsl:text>d </xsl:text>
564 <xsl:apply-templates select="*[last()]"/>
565 <xsl:text>}{d </xsl:text>
566 <xsl:apply-templates select="m:bvar"/>
567 <xsl:text>}</xsl:text>
570 <xsl:text>}</xsl:text>
573 <!-- 4.4.5.3 partialdiff -->
574 <xsl:template match="m:apply[*[1][self::m:partialdiff] and m:list and m:ci and count(*)=3]" priority="2">
575 <xsl:text>D_{</xsl:text>
576 <xsl:for-each select="m:list[1]/*">
577 <xsl:apply-templates select="."/>
578 <xsl:if test="position()<last()"><xsl:text>, </xsl:text></xsl:if>
580 <xsl:text>}</xsl:text>
581 <xsl:apply-templates select="*[3]"/>
584 <xsl:template match="m:apply[*[1][self::m:partialdiff]]" priority="1">
585 <xsl:text>\frac{\partial^{</xsl:text>
587 <xsl:when test="m:degree">
588 <xsl:apply-templates select="m:degree/node()"/>
590 <xsl:when test="m:bvar/m:degree[string(number(.))='NaN']">
591 <xsl:for-each select="m:bvar/m:degree">
592 <xsl:apply-templates select="node()"/>
593 <xsl:if test="position()<last()"><xsl:text>+</xsl:text></xsl:if>
595 <xsl:if test="count(m:bvar[not(m:degree)])>0">
596 <xsl:text>+</xsl:text>
597 <xsl:value-of select="count(m:bvar[not(m:degree)])"/>
601 <xsl:value-of select="sum(m:bvar/m:degree)+count(m:bvar[not(m:degree)])"/>
604 <xsl:text>}</xsl:text>
605 <xsl:apply-templates select="*[last()]"/>
606 <xsl:text>}{</xsl:text>
607 <xsl:for-each select="m:bvar">
608 <xsl:text>\partial </xsl:text>
609 <xsl:apply-templates select="node()"/>
610 <xsl:if test="m:degree">
611 <xsl:text>^{</xsl:text>
612 <xsl:apply-templates select="m:degree/node()"/>
613 <xsl:text>}</xsl:text>
616 <xsl:text>}</xsl:text>
619 <!-- 4.4.2.8 declare 4.4.5.4 lowlimit 4.4.5.5 uplimit 4.4.5.7 degree 4.4.9.5 momentabout -->
620 <xsl:template match="m:declare | m:lowlimit | m:uplimit | m:degree | m:momentabout"/>
623 <xsl:template match="m:bvar">
624 <xsl:apply-templates/>
625 <xsl:if test="following-sibling::m:bvar"><xsl:text>, </xsl:text></xsl:if>
628 <!-- 4.4.5.8 divergence-->
629 <xsl:template match="m:divergence"><xsl:text>\mathop{\mathrm{div}}</xsl:text></xsl:template>
631 <!-- 4.4.5.11 laplacian-->
632 <xsl:template match="m:laplacian"><xsl:text>\nabla^2 </xsl:text></xsl:template>
635 <xsl:template match="m:set">
636 <xsl:text>\{</xsl:text><xsl:call-template name="set"/><xsl:text>\}</xsl:text>
639 <!-- 4.4.6.2 list -->
640 <xsl:template match="m:list">
641 <xsl:text>\left[</xsl:text><xsl:call-template name="set"/><xsl:text>\right]</xsl:text>
644 <xsl:template name="set">
646 <xsl:when test="m:condition">
647 <xsl:apply-templates select="m:bvar/*[not(self::bvar or self::condition)]"/>
648 <xsl:text>\colon </xsl:text>
649 <xsl:apply-templates select="m:condition/node()"/>
652 <xsl:for-each select="*">
653 <xsl:apply-templates select="."/>
654 <xsl:if test="position()!=last()"><xsl:text>, </xsl:text></xsl:if>
660 <!-- 4.4.6.3 union -->
661 <xsl:template match="m:apply[*[1][self::m:union]]">
662 <xsl:param name="p" select="0"/>
663 <xsl:call-template name="infix">
664 <xsl:with-param name="this-p" select="2"/>
665 <xsl:with-param name="p" select="$p"/>
666 <xsl:with-param name="mo">\cup </xsl:with-param>
670 <!-- 4.4.6.4 intersect -->
671 <xsl:template match="m:apply[*[1][self::m:intersect]]">
672 <xsl:param name="p" select="0"/>
673 <xsl:call-template name="infix">
674 <xsl:with-param name="this-p" select="3"/>
675 <xsl:with-param name="p" select="$p"/>
676 <xsl:with-param name="mo">\cap </xsl:with-param>
681 <xsl:template match="m:apply[*[1][self::m:in]]">
682 <xsl:param name="p" select="0"/>
683 <xsl:call-template name="binary">
684 <xsl:with-param name="mo">\in </xsl:with-param>
685 <xsl:with-param name="p" select="$p"/>
686 <xsl:with-param name="this-p" select="3"/>
690 <!-- 4.4.6.5 notin -->
691 <xsl:template match="m:apply[*[1][self::m:notin]]">
692 <xsl:param name="p" select="0"/>
693 <xsl:call-template name="binary">
694 <xsl:with-param name="mo">\notin </xsl:with-param>
695 <xsl:with-param name="p" select="$p"/>
696 <xsl:with-param name="this-p" select="3"/>
700 <!-- 4.4.6.7 subset -->
701 <xsl:template match="m:apply[*[1][self::m:subset]]">
702 <xsl:param name="p" select="0"/>
703 <xsl:call-template name="infix">
704 <xsl:with-param name="this-p" select="2"/>
705 <xsl:with-param name="p" select="$p"/>
706 <xsl:with-param name="mo">\subseteq </xsl:with-param>
710 <!-- 4.4.6.8 prsubset -->
711 <xsl:template match="m:apply[*[1][self::m:prsubset]]">
712 <xsl:param name="p" select="0"/>
713 <xsl:call-template name="infix">
714 <xsl:with-param name="this-p" select="2"/>
715 <xsl:with-param name="p" select="$p"/>
716 <xsl:with-param name="mo">\subset </xsl:with-param>
720 <!-- 4.4.6.9 notsubset -->
721 <xsl:template match="m:apply[*[1][self::m:notsubset]]">
722 <xsl:param name="p" select="0"/>
723 <xsl:call-template name="binary">
724 <xsl:with-param name="this-p" select="2"/>
725 <xsl:with-param name="p" select="$p"/>
726 <xsl:with-param name="mo">\nsubseteq </xsl:with-param>
730 <!-- 4.4.6.10 notprsubset -->
731 <xsl:template match="m:apply[*[1][self::m:notprsubset]]">
732 <xsl:param name="p" select="0"/>
733 <xsl:call-template name="binary">
734 <xsl:with-param name="this-p" select="2"/>
735 <xsl:with-param name="p" select="$p"/>
736 <xsl:with-param name="mo">\not\subset </xsl:with-param>
740 <!-- 4.4.6.11 setdiff -->
741 <xsl:template match="m:apply[*[1][self::m:setdiff]]">
742 <xsl:param name="p" select="0"/>
743 <xsl:call-template name="binary">
744 <xsl:with-param name="this-p" select="2"/>
745 <xsl:with-param name="p" select="$p"/>
746 <xsl:with-param name="mo">\setminus </xsl:with-param>
750 <!-- 4.4.6.12 card -->
751 <xsl:template match="m:apply[*[1][self::m:card]]">
752 <xsl:text>|</xsl:text>
753 <xsl:apply-templates select="*[2]"/>
754 <xsl:text>|</xsl:text>
757 <!-- 4.4.6.13 cartesianproduct 4.4.10.6 vectorproduct -->
758 <xsl:template match="m:apply[*[1][self::m:cartesianproduct or self::m:vectorproduct]]">
759 <xsl:param name="p" select="0"/>
760 <xsl:call-template name="infix">
761 <xsl:with-param name="this-p" select="2"/>
762 <xsl:with-param name="p" select="$p"/>
763 <xsl:with-param name="mo">\times </xsl:with-param>
768 match="m:apply[*[1][self::m:cartesianproduct][count(following-sibling::m:reals)=count(following-sibling::*)]]"
770 <xsl:apply-templates select="*[2]">
771 <xsl:with-param name="p" select="5"/>
772 </xsl:apply-templates>
773 <xsl:text>^{</xsl:text>
774 <xsl:value-of select="count(*)-1"/>
775 <xsl:text>}</xsl:text>
779 <xsl:template match="m:apply[*[1][self::m:sum]]">
780 <xsl:text>\sum</xsl:text><xsl:call-template name="series"/>
783 <!-- 4.4.7.2 product -->
784 <xsl:template match="m:apply[*[1][self::m:product]]">
785 <xsl:text>\prod</xsl:text><xsl:call-template name="series"/>
788 <xsl:template name="series">
789 <xsl:if test="m:lowlimit/*|m:interval/*[1]|m:condition/*">
790 <xsl:text>_{</xsl:text>
791 <xsl:if test="not(m:condition)">
792 <xsl:apply-templates select="m:bvar"/>
793 <xsl:text>=</xsl:text>
795 <xsl:apply-templates select="m:lowlimit/*|m:interval/*[1]|m:condition/*"/>
796 <xsl:text>}</xsl:text>
798 <xsl:if test="m:uplimit/*|m:interval/*[2]">
799 <xsl:text>^{</xsl:text>
800 <xsl:apply-templates select="m:uplimit/*|m:interval/*[2]"/>
801 <xsl:text>}</xsl:text>
803 <xsl:text> </xsl:text>
804 <xsl:apply-templates select="*[last()]"/>
807 <!-- 4.4.7.3 limit -->
808 <xsl:template match="m:apply[*[1][self::m:limit]]">
809 <xsl:text>\lim_{</xsl:text>
810 <xsl:apply-templates select="m:lowlimit|m:condition/*"/>
811 <xsl:text>}</xsl:text>
812 <xsl:apply-templates select="*[last()]"/>
815 <xsl:template match="m:apply[m:limit]/m:lowlimit" priority="3">
816 <xsl:apply-templates select="../m:bvar/node()"/>
817 <xsl:text>\to </xsl:text>
818 <xsl:apply-templates/>
821 <!-- 4.4.7.4 tendsto -->
822 <xsl:template match="m:apply[*[1][self::m:tendsto]]">
823 <xsl:param name="p"/>
824 <xsl:call-template name="binary">
825 <xsl:with-param name="this-p" select="2"/>
826 <xsl:with-param name="p" select="$p"/>
827 <xsl:with-param name="mo">
829 <xsl:when test="@type='above'">\searrow </xsl:when>
830 <xsl:when test="@type='below'">\nearrow </xsl:when>
831 <xsl:when test="@type='two-sided'">\rightarrow </xsl:when>
832 <xsl:otherwise>\to </xsl:otherwise>
838 <!-- 4.4.8.1 common tringonometric functions 4.4.8.3 natural logarithm -->
839 <xsl:template match="m:apply[*[1][
840 self::m:sin or self::m:cos or self::m:tan or self::m:sec or
841 self::m:csc or self::m:cot or self::m:sinh or self::m:cosh or
842 self::m:tanh or self::m:coth or self::m:arcsin or self::m:arccos or
843 self::m:arctan or self::m:ln]]">
844 <xsl:text>\</xsl:text>
845 <xsl:value-of select="local-name(*[1])"/>
846 <xsl:text> </xsl:text>
847 <xsl:apply-templates select="*[2]">
848 <xsl:with-param name="p" select="7"/>
849 </xsl:apply-templates>
852 <xsl:template match="m:sin | m:cos | m:tan | m:sec | m:csc |
853 m:cot | m:sinh | m:cosh | m:tanh | m:coth |
854 m:arcsin | m:arccos | m:arctan | m:ln">
855 <xsl:text>\</xsl:text>
856 <xsl:value-of select="local-name(.)"/>
857 <xsl:text> </xsl:text>
860 <xsl:template match="m:apply[*[1][
861 self::m:sech or self::m:csch or self::m:arccosh or
862 self::m:arccot or self::m:arccoth or self::m:arccsc or
863 self::m:arccsch or self::m:arcsec or self::m:arcsech or
864 self::m:arcsinh or self::m:arctanh]]">
865 <xsl:text>\mathrm{</xsl:text>
866 <xsl:value-of select="local-name(*[1])"/>
867 <xsl:text>\,}</xsl:text>
868 <xsl:apply-templates select="*[2]">
869 <xsl:with-param name="p" select="7"/>
870 </xsl:apply-templates>
873 <xsl:template match="m:sech | m:csch | m:arccosh | m:arccot |
874 m:arccoth | m:arccsc |m:arccsch |m:arcsec |
875 m:arcsech | m:arcsinh | m:arctanh">
876 <xsl:text>\mathrm{</xsl:text>
877 <xsl:value-of select="local-name(.)"/>
878 <xsl:text>}</xsl:text>
882 <xsl:template match="m:apply[*[1][self::m:exp]]">
883 <xsl:text>e^{</xsl:text><xsl:apply-templates select="*[2]"/><xsl:text>}</xsl:text>
887 <xsl:template match="m:apply[*[1][self::m:log]]">
888 <xsl:text>\lg </xsl:text>
889 <xsl:apply-templates select="*[last()]">
890 <xsl:with-param name="p" select="7"/>
891 </xsl:apply-templates>
894 <xsl:template match="m:apply[*[1][self::m:log] and m:logbase != 10]">
895 <xsl:text>\log_{</xsl:text>
896 <xsl:apply-templates select="m:logbase/node()"/>
897 <xsl:text>}</xsl:text>
898 <xsl:apply-templates select="*[last()]">
899 <xsl:with-param name="p" select="7"/>
900 </xsl:apply-templates>
903 <!-- 4.4.9.1 mean -->
904 <xsl:template match="m:apply[*[1][self::m:mean]]">
905 <xsl:text>\langle </xsl:text>
906 <xsl:for-each select="*[position()>1]">
907 <xsl:apply-templates select="."/>
908 <xsl:if test="position() !=last()"><xsl:text>, </xsl:text></xsl:if>
910 <xsl:text>\rangle </xsl:text>
913 <!-- 4.4.9.2 sdef -->
914 <xsl:template match="m:sdev"><xsl:text>\sigma </xsl:text></xsl:template>
916 <!-- 4.4.9.3 variance -->
917 <xsl:template match="m:apply[*[1][self::m:variance]]">
918 <xsl:text>\sigma(</xsl:text>
919 <xsl:apply-templates select="*[2]"/>
920 <xsl:text>)^2</xsl:text>
923 <!-- 4.4.9.5 moment -->
924 <xsl:template match="m:apply[*[1][self::m:moment]]">
925 <xsl:text>\langle </xsl:text>
926 <xsl:apply-templates select="*[last()]"/>
927 <xsl:text>^{</xsl:text>
928 <xsl:apply-templates select="m:degree/node()"/>
929 <xsl:text>}\rangle</xsl:text>
930 <xsl:if test="m:momentabout">
931 <xsl:text>_{</xsl:text>
932 <xsl:apply-templates select="m:momentabout/node()"/>
933 <xsl:text>}</xsl:text>
935 <xsl:text> </xsl:text>
938 <!-- 4.4.10.1 vector -->
939 <xsl:template match="m:vector">
940 <xsl:text>\left(\begin{array}{c}</xsl:text>
941 <xsl:for-each select="*">
942 <xsl:apply-templates select="."/>
943 <xsl:if test="position()!=last()"><xsl:text>\\ </xsl:text></xsl:if>
945 <xsl:text>\end{array}\right)</xsl:text>
948 <!-- 4.4.10.2 matrix -->
949 <xsl:template match="m:matrix">
950 <xsl:text>\begin{pmatrix}</xsl:text>
951 <xsl:apply-templates/>
952 <xsl:text>\end{pmatrix}</xsl:text>
955 <!-- 4.4.10.3 matrixrow -->
956 <xsl:template match="m:matrixrow">
957 <xsl:for-each select="*">
958 <xsl:apply-templates select="."/>
959 <xsl:if test="position()!=last()"><xsl:text> & </xsl:text></xsl:if>
961 <xsl:if test="position()!=last()"><xsl:text>\\ </xsl:text></xsl:if>
964 <!-- 4.4.10.4 determinant -->
965 <xsl:template match="m:apply[*[1][self::m:determinant]]">
966 <xsl:text>\det </xsl:text>
967 <xsl:apply-templates select="*[2]">
968 <xsl:with-param name="p" select="7"/>
969 </xsl:apply-templates>
972 <xsl:template match="m:apply[*[1][self::m:determinant]][*[2][self::m:matrix]]" priority="2">
973 <xsl:text>\begin{vmatrix}</xsl:text>
974 <xsl:apply-templates select="m:matrix/*"/>
975 <xsl:text>\end{vmatrix}</xsl:text>
978 <!-- 4.4.10.5 transpose -->
979 <xsl:template match="m:apply[*[1][self::m:transpose]]">
980 <xsl:apply-templates select="*[2]">
981 <xsl:with-param name="p" select="7"/>
982 </xsl:apply-templates>
983 <xsl:text>^T</xsl:text>
986 <!-- 4.4.10.5 selector -->
987 <xsl:template match="m:apply[*[1][self::m:selector]]">
988 <xsl:apply-templates select="*[2]">
989 <xsl:with-param name="p" select="7"/>
990 </xsl:apply-templates>
991 <xsl:text>_{</xsl:text>
992 <xsl:for-each select="*[position()>2]">
993 <xsl:apply-templates select="."/>
994 <xsl:if test="position() !=last()"><xsl:text>, </xsl:text></xsl:if>
996 <xsl:text>}</xsl:text>
999 <!-- 4.4.10.7 scalarproduct 4.4.10.8 outerproduct -->
1000 <xsl:template match="m:apply[*[1][self::m:scalarproduct or self::m:outerproduct]]">
1001 <xsl:param name="p" select="0"/>
1002 <xsl:call-template name="infix">
1003 <xsl:with-param name="this-p" select="2"/>
1004 <xsl:with-param name="p" select="$p"/>
1005 <xsl:with-param name="mo">\dot </xsl:with-param>
1006 </xsl:call-template>
1009 <!-- 4.4.11.2 semantics -->
1010 <xsl:template match="m:semantics"><xsl:apply-templates select="*[1]"/></xsl:template>
1012 <xsl:template match="m:semantics[m:annotation/@encoding='TeX']">
1013 <xsl:apply-templates select="m:annotation[@encoding='TeX']/node()"/>
1016 <!-- 4.4.12.1 integers -->
1017 <xsl:template match="m:integers"><xsl:text>\mathbb{Z}</xsl:text></xsl:template>
1019 <!-- 4.4.12.2 reals -->
1020 <xsl:template match="m:reals"><xsl:text>\mathbb{R}</xsl:text></xsl:template>
1022 <!-- 4.4.12.3 rationals -->
1023 <xsl:template match="m:rationals"><xsl:text>\mathbb{Q}</xsl:text></xsl:template>
1025 <!-- 4.4.12.4 naturalnumbers -->
1026 <xsl:template match="m:naturalnumbers"><xsl:text>\mathbb{N}</xsl:text></xsl:template>
1028 <!-- 4.4.12.5 complexes -->
1029 <xsl:template match="m:complexes"><xsl:text>\mathbb{C}</xsl:text></xsl:template>
1031 <!-- 4.4.12.6 primes -->
1032 <xsl:template match="m:primes"><xsl:text>\mathbb{P}</xsl:text></xsl:template>
1034 <!-- 4.4.12.7 exponentiale -->
1035 <xsl:template match="m:exponentiale"><xsl:text>e</xsl:text></xsl:template>
1037 <!-- 4.4.12.8 imaginaryi -->
1038 <xsl:template match="m:imaginaryi"><xsl:text>i</xsl:text></xsl:template>
1040 <!-- 4.4.12.9 notanumber -->
1041 <xsl:template match="m:notanumber"><xsl:text>NaN</xsl:text></xsl:template>
1043 <!-- 4.4.12.10 true -->
1044 <xsl:template match="m:true"><xsl:text>\mbox{true}</xsl:text></xsl:template>
1046 <!-- 4.4.12.11 false -->
1047 <xsl:template match="m:false"><xsl:text>\mbox{false}</xsl:text></xsl:template>
1049 <!-- 4.4.12.12 emptyset -->
1050 <xsl:template match="m:emptyset"><xsl:text>\emptyset </xsl:text></xsl:template>
1052 <!-- 4.4.12.13 pi -->
1053 <xsl:template match="m:pi"><xsl:text>\pi </xsl:text></xsl:template>
1055 <!-- 4.4.12.14 eulergamma -->
1056 <xsl:template match="m:eulergamma"><xsl:text>\gamma </xsl:text></xsl:template>
1058 <!-- 4.4.12.15 infinity -->
1059 <xsl:template match="m:infinity"><xsl:text>\infty </xsl:text></xsl:template>
1061 <!-- ****************************** -->
1062 <xsl:template name="infix" >
1063 <xsl:param name="mo"/>
1064 <xsl:param name="p" select="0"/>
1065 <xsl:param name="this-p" select="0"/>
1066 <xsl:if test="$this-p < $p"><xsl:text>(</xsl:text></xsl:if>
1067 <xsl:for-each select="*[position()>1]">
1068 <xsl:if test="position() > 1">
1069 <xsl:copy-of select="$mo"/>
1071 <xsl:apply-templates select=".">
1072 <xsl:with-param name="p" select="$this-p"/>
1073 </xsl:apply-templates>
1075 <xsl:if test="$this-p < $p"><xsl:text>)</xsl:text></xsl:if>
1078 <xsl:template name="binary" >
1079 <xsl:param name="mo"/>
1080 <xsl:param name="p" select="0"/>
1081 <xsl:param name="this-p" select="0"/>
1082 <xsl:if test="$this-p < $p"><xsl:text>(</xsl:text></xsl:if>
1083 <xsl:apply-templates select="*[2]">
1084 <xsl:with-param name="p" select="$this-p"/>
1085 </xsl:apply-templates>
1086 <xsl:value-of select="$mo"/>
1087 <xsl:apply-templates select="*[3]">
1088 <xsl:with-param name="p" select="$this-p"/>
1089 </xsl:apply-templates>
1090 <xsl:if test="$this-p < $p"><xsl:text>)</xsl:text></xsl:if>