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:
Write a specification file and add the relevant attributes to
title(see Customizing a title page indirectly).Modify the
title-template in modechapter.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:blocksuch asfont-family,font-sizeand 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.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top