XML technologies / DocBook / Generating FO (PDF) / Formatting headings / Customizing chapter headings

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

There are two ways to customize chapter headings:

  1. Write a specification file and add the relevant attributes to title (see Customizing a title page indirectly).

  2. Modify the title-template in mode chapter.titlepage.recto.auto.mode.

This section considers only the second method. For example, use the following template to place the chapter number and title on separate lines:

<xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
    <fo:block>
        <fo:block>
            <xsl:call-template name="gentext">
                <xsl:with-param name="key" select="'chapter'"/>
            </xsl:call-template>
            <xsl:text> </xsl:text>
            <xsl:apply-templates select="ancestor-or-self::d:chapter[1]" mode="label.markup"/>
        </fo:block>
        <fo:block>
            <xsl:apply-templates select="." mode="title.markup"/>
        </fo:block>
    </fo:block>
</xsl:template>

Line 2: Add attributes to this fo:block such as font-family, font-size and so on.
Line 4: Generates the word for chapter in the configured language.
Line 8: Inserts the current chapter number.
Line 11: Inserts the current title.

When using DocBook 5, remember the namespace-prefix for title.

This template allows many variations. Attributes on the first fo:block control font size, font family, spacing above and much more.

The same mechanism applies to other structural elements, such as appendix and others. Simply adjust the mode accordingly.

  

back to top