<?xml version="1.0" encoding="utf-8"?> <!-- Various mathematical operators and symbols. We get around the problem of math vs. non-math mode operators in LaTeX by liberally sprinkling \ensuremath around. If we're not in math mode, it enables it, and if we're already in math mode, it ignores it. This means we don't need identical templates for math and non-math modes. Yay! Note that some operators (binary in particular) need spaces around them in the HTML templates, as they seem to get munched otherwise. The "strip" mode forms of the templates are for use in the context of an HTML <title> element (so the mode is only relevant to the HTML formats). Embedding HTML markup inside the <title> element causes the markup to appear verbatim in the window title, i.e., <title><em>foo</em> bar</title> will appear in the window title as "<em>foo</em> bar", not "foo bar". Putting the stylesheet into strip mode means that it will only output text nodes unless otherwise specified for a particular element. Generally the "strip" templates will simply call-template to the original, unless the original contains markup that needs to be eliminated (e.g., see space below). The downside of this approach, of course, is that you need "strip" mode templates for quite a lot of things, but that can't really be helped. --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- BASIC OPERATORS AND SYMBOLS. --> <!-- Addition binary operation symbol (+). --> <template name="plus-operator" match="plus|plus-sign"> <!-- U+002B PLUS SIGN --> <common><xsl:text>+</xsl:text></common> </template> <!-- Multiplication binary operation symbol (×). --> <template name="times-operator" match="times|multiply|multiplication|multiplication-sign"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\times}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&times;</xsl:text></html> <!-- U+00D7 MULTIPLICATION SIGN --> <xhtml><span class="unicode"><xsl:text>×</xsl:text></span></xhtml> </template> <!-- Subtraction binary operation symbol (−). --> <template name="minus-operator" match="minus|subtract|minus-sign"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{-}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&minus;</xsl:text></html> <!-- U+2212 MINUS SIGN --> <xhtml><span class="unicode"><xsl:text>−</xsl:text></span></xhtml> </template> <!-- Division binary operation symbol (∕). --> <template name="divide-operator" match="divide|division|division-slash"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{/}</xsl:text></common> <html><xsl:text>/</xsl:text></html> <!-- U+2215 DIVISION SLASH --> <xhtml><span class="unicode"><xsl:text>∕</xsl:text></span></xhtml> </template> <!-- Equality relation symbol (=). --> <template name="equals-operator" match="equals|eq|equals-sign|equality"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{=}</xsl:text></common> <!-- U+003D EQUALS SIGN --> <common formats="/html/xhtml/"><xsl:text> = </xsl:text></common> </template> <!-- Inequality relation symbol (≠). --> <template name="not-equals-operator" match="not-equals|ne|inequality|not-equal-to"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\neq}</xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &ne; </xsl:text></html> <!-- U+2260 NOT EQUAL TO --> <xhtml><xsl:text> ≠ </xsl:text></xhtml> </template> <!-- Approximation relation symbol (≈). --> <template name="approximately-equals-operator" match="approximately-equals|approximately-equal-to|approx|almost-equal-to"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\approx}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&asymp;</xsl:text></html> <!-- U+2248 ALMOST EQUAL TO --> <xhtml><xsl:text>≈</xsl:text></xhtml> </template> <!-- Greater than relation symbol (>). --> <template name="greater-than-operator" match="greater-than|gt|greater-than-sign"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{>}</xsl:text></common> <!-- U+003E GREATER-THAN SIGN --> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes"> &gt; </xsl:text></common> </template> <!-- Greater than or equal to relation symbol (≥). --> <template name="greater-equals-operator" match="greater-equals|ge|greater-than-or-equal-to"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\geq}</xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &ge; </xsl:text></html> <!-- U+2265 GREATER-THAN OR EQUAL TO --> <xhtml><xsl:text> ≥ </xsl:text></xhtml> </template> <!-- Less than relation symbol (<). --> <template name="less-than-operator" match="less-than|lt|less-than-sign"> <common formats="/latex/xelatex/"><xsl:text> \ensuremath{<} </xsl:text></common> <!-- U+003C LESS-THAN SIGN --> <common formats="/html/xhtml/"><xsl:text disable-output-escaping="yes"> &lt; </xsl:text></common> </template> <!-- Less than or equal to relation symbol (≤). --> <template name="less-equals-operator" match="less-equals|le|less-than-or-equal-to"> <common formats="/latex/xelatex/"><xsl:text> \ensuremath{\leq} </xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &le; </xsl:text></html> <!-- U+2264 LESS-THAN OR EQUAL TO --> <xhtml><xsl:text> ≤ </xsl:text></xhtml> </template> <!-- SYMBOLS RELATING TO SETS. --> <!-- Empty set symbol (∅). --> <template name="empty-set-sign" match="empty-set-sign|empty-set|null"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\emptyset}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&empty;</xsl:text></html> <!-- U+2205 EMPTY SET --> <xhtml><span class="unicode"><xsl:text>∅</xsl:text></span></xhtml> </template> <template name="empty-set-sign-strip" match="empty-set-sign|empty-set|null" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="empty-set-sign" /> </common> </template> <!-- Element-of relation symbol (∈). --> <template name="element-sign" match="element-sign|element|element-of|is-element-of|is-an-element-of"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\in}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&isin;</xsl:text></html> <!-- U+2208 ELEMENT OF --> <xhtml><span class="unicode"><xsl:text>∈</xsl:text></span></xhtml> </template> <template name="element-sign-strip" match="element-sign|element|element-of|is-element-of|is-an-element-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="element-sign" /> </common> </template> <!-- Not-element-of relation symbol (∉). --> <template name="not-element-sign" match="not-element-sign|not-element|not-element-of|is-not-element-of|is-not-an-element-of|not-an-element-of"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\not\in}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&notin;</xsl:text></html> <!-- U+2209 NOT AN ELEMENT OF --> <xhtml><span class="unicode"><xsl:text>∉</xsl:text></span></xhtml> </template> <template name="not-element-sign-strip" match="not-element-sign|not-element|not-element-of|is-not-element-of|is-not-an-element-of|not-an-element-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="not-element-sign" /> </common> </template> <!-- Intersection binary operation symbol (∩). --> <template name="intersect-operator" match="intersect-operator|intersect|intersection|cap"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\cap}</xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &cap; </xsl:text></html> <!-- U+2229 INTERSECTION --> <xhtml><span class="unicode"><xsl:text> ∩ </xsl:text></span></xhtml> </template> <template name="intersect-operator-strip" match="intersect-operator|intersect|intersection|cap" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="intersect-operator" /> </common> </template> <!-- Union binary operation symbol (∪). --> <template name="union-operator" match="union-operator|union|cup"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\cup}</xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &cup; </xsl:text></html> <!-- U+222A UNION --> <xhtml><span class="unicode"><xsl:text> ∪ </xsl:text></span></xhtml> </template> <template name="union-operator-strip" match="union-operator|union|cup" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="union-operator" /> </common> </template> <!-- Strict subset relation symbol (⊂). --> <template name="strict-subset-sign" match="subset-sign|subset|subset-of|is-subset-of|is-a-subset-of|strict-subset"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\subset}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&sub;</xsl:text></html> <!-- U+2282 SUBSET OF --> <xhtml><span class="unicode"><xsl:text>⊂</xsl:text></span></xhtml> </template> <template name="strict-subset-sign-strip" match="subset-sign|subset|subset-of|is-subset-of|is-a-subset-of|strict-subset" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="strict-subset-sign" /> </common> </template> <!-- Strict superset relation symbol (⊃). --> <template name="strict-superset-sign" match="superset-sign|superset|superset-of|is-superset-of|is-a-superset-of"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\supset}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&sup;</xsl:text></html> <!-- U+2283 SUPERSET OF --> <xhtml><span class="unicode"><xsl:text>⊃</xsl:text></span></xhtml> </template> <template name="strict-superset-sign-strip" match="superset-sign|superset|superset-of|is-superset-of|is-a-superset-of" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="strict-superset-sign" /> </common> </template> <!-- Inclusive subset relation symbol (⊆). --> <template name="inclusive-subset-sign" match="inclusive-subset|subset-or-equal|subset-of-or-equal-to|is-subset-of-or-equal-to|is-a-subset-of-or-equal-to"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\subseteq}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&sube;</xsl:text></html> <!-- U+2286 SUBSET OF OR EQUAL TO --> <xhtml><span class="unicode"><xsl:text>⊆</xsl:text></span></xhtml> </template> <template name="inclusive-subset-sign-strip" match="inclusive-subset|subset-or-equal|subset-of-or-equal-to|is-subset-of-or-equal-to|is-a-subset-of-or-equal-to" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="inclusive-subset-sign" /> </common> </template> <!-- Inclusive superset relation symbol (⊇). --> <template name="inclusive-superset-sign" match="inclusive-superset|superset-or-equal|superset-of-or-equal-to|is-superset-of-or-equal-to|is-a-superset-of-or-equal-to"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\supset}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&supe;</xsl:text></html> <!-- U+2287 SUPERSET OF OR EQUAL TO --> <xhtml><span class="unicode"><xsl:text>⊇</xsl:text></span></xhtml> </template> <template name="inclusive-superset-sign-strip" match="inclusive-superset|superset-or-equal|superset-of-or-equal-to|is-superset-of-or-equal-to|is-a-superset-of-or-equal-to" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="inclusive-superset-sign" /> </common> </template> <!-- SYMBOLS RELATING TO LOGIC. --> <!-- Logical NOT binary operation symbol (¬). --> <template name="logical-not-operator" match="logical-not-operator|logical-negation-operator|logical-negation|logical-not|not|negation|neg|not-sign"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\neg}</xsl:text></common> <html><xsl:text disable-output-escaping="yes">&not;</xsl:text></html> <!-- U+00AC NOT SIGN --> <xhtml><span class="unicode"><xsl:text>¬</xsl:text></span></xhtml> </template> <template name="logical-not-operator-strip" match="logical-not-operator|logical-negation-operator|logical-negation|logical-not|not|negation|neg|not-sign" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-not-operator" /> </common> </template> <!-- Logical AND binary operation symbol (∧). --> <template name="logical-and-operator" match="logical-and-operator|logical-and|and|and-operator|hat|wedge"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\wedge}</xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &and; </xsl:text></html> <!-- U+2227 LOGICAL AND --> <xhtml><span class="unicode"><xsl:text> ∧ </xsl:text></span></xhtml> </template> <template name="logical-and-operator-strip" match="logical-and-operator|logical-and|and|and-operator|hat|wedge" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-and-operator" /> </common> </template> <!-- Logical OR binary operation symbol (∨). --> <template name="logical-or-operator" match="logical-or-operator|logical-or|or|or-operator|vee"> <common formats="/latex/xelatex/"><xsl:text>\ensuremath{\vee}</xsl:text></common> <html><xsl:text disable-output-escaping="yes"> &or; </xsl:text></html> <!-- U+2228 LOGICAL OR --> <xhtml><span class="unicode"><xsl:text> ∨ </xsl:text></span></xhtml> </template> <template name="logical-or-operator-strip" match="logical-or-operator|logical-or|or|or-operator|vee" mode="strip"> <common formats="/html/xhtml/"> <xsl:call-template name="logical-or-operator" /> </common> </template> <!-- ARROWS. --> <!-- Rightwards arrow, both single and double (→, ⇒). We can't include the Unicode name in the match list, because the template handles more than one style of arrow. The closest we can manage is "rightwards-arrow". --> <template name="right-arrow" match="right-arrow|rightarrow|implies|rarr|rarrow|rightwards-arrow"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\</xsl:text> <xsl:choose> <xsl:when test="@weight eq 'double'"><xsl:text>R</xsl:text></xsl:when> <xsl:otherwise><xsl:text>r</xsl:text></xsl:otherwise> </xsl:choose> <xsl:text>ightarrow}</xsl:text> </common> <html> <xsl:choose> <xsl:when test="@weight eq 'double'"> <xsl:text disable-output-escaping="yes"> &rArr; </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> &rarr; </xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@weight eq 'double'"> <!-- U+21D2 RIGHTWARDS DOUBLE ARROW --> <span class="unicode"> <xsl:text> ⇒ </xsl:text> </span> </xsl:when> <xsl:otherwise> <!-- U+2192 RIGHTWARDS ARROW --> <xsl:text> → </xsl:text> </xsl:otherwise> </xsl:choose> </xhtml> </template> <!-- Leftwards arrow, both single and double (←, ⇐). We can't include the Unicode name in the match list, because the template handles more than one style of arrow. The closest we can manage is "leftwards-arrow". --> <template name="left-arrow" match="left-arrow|leftarrow|larr|larrow|leftwards-arrow"> <common formats="/latex/xelatex/"> <xsl:text>\ensuremath{\</xsl:text> <xsl:choose> <xsl:when test="@weight eq 'double'"><xsl:text>L</xsl:text></xsl:when> <xsl:otherwise><xsl:text>l</xsl:text></xsl:otherwise> </xsl:choose> <xsl:text>eftarrow}</xsl:text> </common> <html> <xsl:choose> <xsl:when test="@weight eq 'double'"> <xsl:text disable-output-escaping="yes"> &lArr; </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> &larr; </xsl:text> </xsl:otherwise> </xsl:choose> </html> <xhtml> <xsl:choose> <xsl:when test="@weight eq 'double'"> <!-- U+21D0 LEFTWARDS DOUBLE ARROW --> <xsl:text> ⇐ </xsl:text> </xsl:when> <xsl:otherwise> <!-- U+2190 LEFTWARDS ARROW --> <xsl:text> ← </xsl:text> </xsl:otherwise> </xsl:choose> </xhtml> </template> </stylesheet>