Next / Previous / Contents / NM Tech homepage

11.6. PDF block element customizations

Customizations of block-level elements are presented here in alphabetical order.

11.6.1. Admonitions: caution, important, note, tip, and warning

These five elements, collectively known as admonitions, are formatted in the stock templates as slightly narrower blocks with the admonition type (e.g., “Warning”) as a larger heading above the content.

To make these elements stand out more (and in hopes that someone might actually read them!) we wrap them in a gray border. This customization is covered on p. 209ff of Stayton; the template is a copy of the one from fo/admon.xsl.

zdp_fo.xsl
<!--Wraps the argument in a narrow gray border-->
<xsl:template name="nongraphical.admonition">
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>
  </xsl:variable>

The only change we make to the stock template is the lines starting with “border="…"”, which add a solid gray border 4 points wide, and an extra 4 points of padding to keep the contents from touching the inside of the border.

zdp_fo.xsl
  <fo:block space-before.minimum="0.8em"
            space-before.optimum="1em"
            space-before.maximum="1.2em"
            start-indent="0.25in"
            end-indent="0.25in"
            border="4pt solid #d0d0d0"
            padding="4pt"
            id="{$id}">
    <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:block>
</xsl:template>