<?xml version="1.0" encoding="utf-8"?> <!-- "Floating" items (in the LaTeX sense), including formal figures and tables. All these elements have the following attribute(s): @border-placement: The style of border to place around the figure or table. 'none' [default] 'box' or: any combination of 'top', 'left', 'bottom', 'right', e.g., 'bottom, left' (not all options may be available) --> <stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Figures. --> <template name="figure" match="figure"> <common formats="/latex/xelatex/"> <xsl:text>\begin{figure}</xsl:text> <xsl:if test="@latex-placement"> <xsl:text>[</xsl:text> <xsl:value-of select="@latex-placement" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:call-template name="newline-internal" /> <xsl:text>\centering</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:when> </xsl:choose> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'bottom' )"> <xsl:call-template name="newline-internal" /> <xsl:text>\medskip\hrule</xsl:text> </xsl:when> </xsl:choose> <xsl:call-template name="newline-internal" /> <xsl:if test="count(caption) != 0"> <xsl:text>\caption{</xsl:text> <xsl:apply-templates select="caption" /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:if test="@label"> <xsl:text>\label{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> </xsl:if> <xsl:text>\end{figure}</xsl:text> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <div class="figure" style="text-align: center; margin-top: 2em; margin-bottom: 2em;"> <div> <xsl:attribute name="style"> <xsl:if test="@border-placement = 'box'"> <xsl:text>border: 1px solid black; padding: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'top' )"> <xsl:text>border-top: 1px solid black; padding-top: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'left' )"> <xsl:text>border-left: 1px solid black; padding-left: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'bottom' )"> <xsl:text>border-bottom: 1px solid black; padding-bottom: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'right' )"> <xsl:text>border-right: 1px solid black; padding-right: 1em; </xsl:text> </xsl:if> </xsl:attribute> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> </div> <xsl:if test="count(caption) != 0"> <br /> <xsl:apply-templates select="caption" /> </xsl:if> </div> </common> </template> <!-- Tables. --> <template name="table" match="table"> <common formats="/latex/xelatex/"> <xsl:text>\begin{table}</xsl:text> <xsl:if test="@latex-placement"> <xsl:text>[</xsl:text> <xsl:value-of select="@latex-placement" /> <xsl:text>]</xsl:text> </xsl:if> <xsl:call-template name="newline-internal" /> <xsl:text>\centering</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:choose> <!-- TODO: test this with embedded tabulars. It might not work! --> <xsl:when test="@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:when> </xsl:choose> <xsl:apply-templates select="*[not(self::caption)]" /> <xsl:choose> <xsl:when test="@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( @border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:when> </xsl:choose> <xsl:call-template name="newline-internal" /> <xsl:if test="count(caption) != 0"> <xsl:text>\caption{</xsl:text> <xsl:apply-templates select="caption" /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:if test="@label"> <xsl:text>\label{</xsl:text> <xsl:value-of select="@label" /> <xsl:text>}</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:if> </xsl:if> <xsl:text>\end{table}</xsl:text> <xsl:call-template name="newline-internal" /> </common> <common formats="/html/xhtml/"> <div class="table" style="text-align: center; margin-top: 2em; margin-bottom: 2em;"> <div> <xsl:attribute name="style"> <xsl:if test="@border-placement = 'box'"> <xsl:text>border: 1px solid black; padding: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'top' )"> <xsl:text>border-top: 1px solid black; padding-top: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'left' )"> <xsl:text>border-left: 1px solid black; padding-left: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'bottom' )"> <xsl:text>border-bottom: 1px solid black; padding-bottom: 1em; </xsl:text> </xsl:if> <xsl:if test="contains( @border-placement, 'right' )"> <xsl:text>border-right: 1px solid black; padding-right: 1em; </xsl:text> </xsl:if> </xsl:attribute> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:apply-templates select="*[not(self::caption)]" /> </div> <xsl:if test="@label"><a id="{@label}"></a></xsl:if> <xsl:if test="count(caption) != 0"> <br /> <xsl:apply-templates select="caption" /> </xsl:if> </div> </common> </template> <!-- A multi-part table, i.e., one that spans multiple pages. Only relevant for LaTeX, as HTML doesn't have pages. --> <template name="multipart-table" match="table[count(part) gt 0]"> <common formats="/latex/xelatex/"> <xsl:for-each select="part"> <xsl:text>\begin{table}[p]</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\centering</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:choose> <!-- TODO: test this with embedded tabulars. It might not work! --> <xsl:when test="../@border-placement = 'box'"> <xsl:text>\fbox{</xsl:text> </xsl:when> <xsl:when test="contains( ../@border-placement, 'top' )"> <xsl:text>\hrule\medskip</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:when> </xsl:choose> <xsl:apply-templates /> <xsl:choose> <xsl:when test="../@border-placement = 'box'"> <xsl:text>}</xsl:text> </xsl:when> <xsl:when test="contains( ../@border-placement, 'bottom' )"> <xsl:text>\medskip\hrule</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:when> </xsl:choose> <xsl:if test="count(../caption) != 0"> <xsl:text>\caption{</xsl:text> <xsl:apply-templates select="../caption" /> <xsl:choose> <xsl:when test="position() gt 1"> <xsl:text> \emph{(continued)}}</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> \emph{(continues over)}}</xsl:text> <xsl:if test="../@label">\label{<xsl:value-of select="../@label" />}</xsl:if> </xsl:otherwise> </xsl:choose> <xsl:call-template name="newline-internal" /> <!-- Consider the possibility of labels for each part? --> <!-- <xsl:if test="@label">\label{<xsl:value-of select="@label" />}</xsl:if> --> </xsl:if> <xsl:text>\end{table}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\addtocounter{table}{-1}</xsl:text> <xsl:call-template name="newline-internal" /> <xsl:text>\clearpage</xsl:text> <xsl:call-template name="newline-internal" /> </xsl:for-each> <xsl:text>\stepcounter{table}</xsl:text> <xsl:call-template name="newline-internal" /> </common> </template> <!-- Captions. --> <template name="figure-caption" match="figure/caption"> <common formats="/latex/xelatex/"> <xsl:apply-templates /> </common> <common formats="/html/xhtml/"> <p style="text-align: center;"> <strong> <xsl:text>Figure </xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="figure" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="figure[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> <xsl:text>. </xsl:text> </strong> <xsl:apply-templates /> </p> </common> </template> <template name="table-caption" match="table/caption"> <common formats="/latex/xelatex/"> <xsl:apply-templates /> </common> <common formats="/html/xhtml/"> <p style="text-align: center;"> <strong> <xsl:text>Table </xsl:text> <xsl:choose> <xsl:when test="$showanswers='yes'"> <xsl:number count="table" level="any" format="1" /> </xsl:when> <xsl:otherwise> <xsl:number count="table[not(ancestor::answer) and not(ancestor::omit) and not(ancestor::comment)]" level="any" format="1" /> </xsl:otherwise> </xsl:choose> <xsl:text>. </xsl:text> </strong> <xsl:apply-templates /> </p> </common> </template> </stylesheet>