XML technologies / DocBook / Generating FO (PDF) / Formatting headings / Formatting structural elements

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

As shown in Formatting structural elements for HTML, for XSL-FO use the same template named component.title. To obtain the same presentation as in HTML, proceed as follows:

  1. Create a customization file as shown in Creating a customization file for XSL-FO.

  2. Copy the template named component.title from the file fo/component.xsl into your customization file.

  3. Find the following code inside the template:

<xsl:variable name="title"> 
    <xsl:apply-templates select="$node" mode="object.title.markup"> 
        <xsl:with-param name="allow-anchors" select="1"/> 
    </xsl:apply-templates> 
</xsl:variable>

  1. Replace the preceding code with the following lines:

<xsl:variable name="title"> 
    <fo:block font-family="{$title.fontset}" text-align="right" keep-together.within-column="always"> 
        <fo:block font-weight="normal" font-size="{$body.font.master * 10.7}pt" padding-end="0pt" margin-right="-12pt" line-height="0.65" space-after="10pt"> 
            <xsl:apply-templates select="$node" mode="label.markup"/> 
        </fo:block> 
        <fo:block font-size="{$body.font.master * 2.48}pt"> 
            <xsl:apply-templates select="$node" mode="title.markup"/> 
        </fo:block> 
    </fo:block> 
</xsl:variable>

Line 2: Creates the surrounding block. This sets alignment and font family.
Line 3: Creates the marker. Its font size is calculated from the parameter body.font.master and a factor. Vertical alignment is adjusted using margin-right slightly to the right. This adjustment depends on the font.
Line 6: Creates the title, using a slightly smaller font size.

  

back to top