diff --git a/modules/basic-page-elements.xml b/modules/basic-page-elements.xml index 8e9b439..1d237d1 100644 --- a/modules/basic-page-elements.xml +++ b/modules/basic-page-elements.xml @@ -136,6 +136,9 @@ <!-- Page break. This is only relevant for LaTeX formats at present. + The page break is automatically suppressed if the parent node is "answer" and $showanswers is "no", or the parent node is "question" and $showanswers is "yes". This is to prevent page breaks that look fine in one but not the other. + If you want to force a page break regardless, put after the "answer" element for a question item. + @print-caption: Whether or not to print a caption before the page break. 'yes' => display the caption otherwise => display nothing [default] @@ -145,25 +148,31 @@ <template name="page-break" match="page-break|new-page|newpage|pagebreak"> <common formats="/latex/xelatex/"> - <xsl:if test="@print-caption = 'yes'"> - <xsl:text>\begin{flushright}</xsl:text> - <xsl:call-template name="newline-internal" /> - <xsl:text>\emph{</xsl:text> - <xsl:choose> - <xsl:when test="@caption-text"> - <xsl:value-of select="@caption-text" /> - </xsl:when> - <xsl:otherwise> - <xsl:text>continues over\ldots</xsl:text> - </xsl:otherwise> - </xsl:choose> - <xsl:text>}</xsl:text> - <xsl:call-template name="newline-internal" /> - <xsl:text>\end{flushright}</xsl:text> - <xsl:call-template name="newline-internal" /> - </xsl:if> - <xsl:text>\newpage</xsl:text> - <xsl:call-template name="newline-internal" /> + <xsl:variable name="insert" select=" + if ((name(..) = 'answer') and ($showanswers = 'no')) then false() + else if ((name(..) = 'question') and ($showanswers = 'yes')) then false() + else true()" /> + <xsl:if test="$insert"> + <xsl:if test="@print-caption = 'yes'"> + <xsl:text>\begin{flushright}</xsl:text> + <xsl:call-template name="newline-internal" /> + <xsl:text>\emph{</xsl:text> + <xsl:choose> + <xsl:when test="@caption-text"> + <xsl:value-of select="@caption-text" /> + </xsl:when> + <xsl:otherwise> + <xsl:text>continues over\ldots</xsl:text> + </xsl:otherwise> + </xsl:choose> + <xsl:text>}</xsl:text> + <xsl:call-template name="newline-internal" /> + <xsl:text>\end{flushright}</xsl:text> + <xsl:call-template name="newline-internal" /> + </xsl:if> + <xsl:text>\newpage</xsl:text> + <xsl:call-template name="newline-internal" /> + </xsl:if> </common> </template>