From: Paul V. <pa...@vi...> - 2004-06-19 11:42:01
|
Hi Carlos, > Hope the above one is more correct, it's the same as the docbook > stylesheet one ...except that you sneakily merged two templates into one, and in doing so disabled graphical admonitions ;-) > but adding the background color: > > <xsl:template match="note|important|warning|caution|tip"> > <xsl:param name="node" select="."/> > <xsl:variable name="id"> > <xsl:call-template name="object.id"/> > </xsl:variable> > <xsl:variable name="color"> > <xsl:choose> > <xsl:when test="name($node)='note'">F0FFFF</xsl:when> > <xsl:when test="name($node)='warning'">FFE4E1</xsl:when> <snip> I think the colored background is a good idea, but only for non-graphical admonitions. (If there's an icon next to the admoniton the background coloring may ruin the appearance, and the icon already attracts the attention anyway.) So in my copy, I overrode the nongraphical.admonition template: <xsl:template name="nongraphical.admonition"> <xsl:variable name="id"> <xsl:call-template name="object.id"/> </xsl:variable> <xsl:variable name="color"> <xsl:choose> <xsl:when test="name()='note'">F0FFFF</xsl:when> <xsl:when test="name()='warning'">FFE4E1</xsl:when> <xsl:when test="name()='caution'">FFE4E1</xsl:when> <xsl:when test="name()='tip'">F0FFFF</xsl:when> <xsl:when test="name()='important'">FFE4E1</xsl:when> </xsl:choose> </xsl:variable> <fo:block space-before.minimum="0.8em" space-before.optimum="1em" space-before.maximum="1.2em" background-color="#{$color}" id="{$id}"> <fo:table> <fo:table-column/> <fo:table-body> <fo:table-row> <fo:table-cell padding="6pt"> <xsl:if test="$admon.textlabel != 0 or title"> <fo:block keep-with-next='always' xsl:use-attribute-sets="admonition.title.properties"> <xsl:apply-templates select="." mode="object.title.markup"/> </fo:block> </xsl:if> <fo:block xsl:use-attribute-sets="admonition.properties"> <xsl:apply-templates/> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> </xsl:template> I didn't add extra indentation because with a bg color I find it nicer if the admonition aligns with the surrounding blocks. The table is necessary because of the padding. If you don't use a table, the text aligns with the surroundings but the padding extends outwards, which I find ugly. Now you *can* compensate the padding with margins or indents, but alas... if you do that, admonitions belonging to already-indented blocks like listitems etc., will then OUTdent, because margins and indents turn out not to be relative to the block, but to the content region. (Maybe there's a simple way around this, but I don't know it...) If you don't want the padding, you also don't need the table. Greetings, Paul Vinkenoog |