diff --git a/modules/tabular.xml b/modules/tabular.xml index 2db4cf2..b0400d5 100644 --- a/modules/tabular.xml +++ b/modules/tabular.xml @@ -30,7 +30,12 @@ 'no' [default] 'yes' - @caption (LaTeX only): Only valid for long tables (@long-table = 'yes'); ignored otherwise. + If @long-table is 'yes', the following changes occur: + tabular-header is repeated on every page of the longtable (\endhead) + tabular-header with @first = 'yes' appears on the first page of the longtable (\endfirsthead) + tabular-footer is repeated on every page of the longtable (\endfoot) + tabular-footer with @last = 'yes' appears on the last page of the longtable (\endlastfoot) + caption is available as a sub-element --> <template name="tabular" match="tabular"> <common formats="/latex/xelatex/"> @@ -80,14 +85,30 @@ <xsl:text>{</xsl:text> <xsl:apply-templates select="tabular-columns" /> <xsl:text>}</xsl:text> - <xsl:if test="(@long-table = ('yes', 'y', 'true', 't', '1')) and @caption"> - <xsl:text>\caption{</xsl:text> - <xsl:value-of select="@caption" /> - <xsl:text>} \\</xsl:text> - </xsl:if> - <xsl:apply-templates select="tabular-header" /> - <xsl:apply-templates select="tabular-body" /> - <xsl:apply-templates select="tabular-footer" /> + <xsl:apply-templates select="tabular-header" /> + <!-- For long tables, we need to do the headers and footers first. --> + <xsl:choose> + <xsl:when test="@long-table = ('yes', 'y', 'true', 't', '1')"> + <xsl:apply-templates select="tabular-footer" /> + <xsl:apply-templates select="tabular-body" /> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="tabular-body" /> + <xsl:apply-templates select="tabular-footer" /> + </xsl:otherwise> + </xsl:choose> + <xsl:if test="@long-table = ('yes', 'y', 'true', 't', '1') and count(caption) ne 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{</xsl:text> <xsl:value-of select=" if (@long-table = ('yes', 'y', 'true', 't', '1')) then 'longtable' @@ -179,7 +200,14 @@ <!-- Tabular header. --> <template name="tabular-header" match="tabular-header"> - <common formats="/latex/xelatex/"><xsl:apply-templates /></common> + <common formats="/latex/xelatex/"> + <xsl:apply-templates /> + <xsl:value-of select=" + if (../@long-table = ('yes', 'y', 'true', 't', '1')) then + if (@first = ('yes', 'y', 'true', 't', '1')) then '\endfirsthead' + else '\endhead' + else ''" /> + </common> <common formats="/html/xhtml/"> <thead> <xsl:apply-templates /> @@ -190,7 +218,14 @@ <!-- Tabular footer. --> <template name="tabular-footer" match="tabular-footer"> - <common formats="/latex/xelatex/"><xsl:apply-templates /></common> + <common formats="/latex/xelatex/"> + <xsl:apply-templates /> + <xsl:value-of select=" + if (../@long-table = ('yes', 'y', 'true', 't', '1')) then + if (@last = ('yes', 'y', 'true', 't', '1')) then '\endlastfoot' + else '\endfoot' + else ''" /> + </common> <common formats="/html/xhtml/"> <tfoot> <xsl:apply-templates /> @@ -553,4 +588,12 @@ </template> + <!-- Long table captions are only relevant in (Xe)LaTeX. --> + <template name="long-table-caption" match="tabular[@long-table = ('yes', 'y', 'true', 't', '1')]/caption"> + <common formats="/latex/xelatex/"> + <xsl:apply-templates /> + </common> + </template> + + </stylesheet>