XML technologies / DocBook / Generating FO (PDF) / Displaying tables of contents / Full-width tables of contents

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

To align page numbers with the right margin, add further attributes to the fo:block in Chapter table of contents at the text width.

<fo:block space-before="0.75em" end-indent="2.5em" last-line-end-indent="-2.5em" text-align="center" text-align-last="justify">
    <fo:basic-link internal-destination="{$id}">
        <xsl:apply-templates select="." mode="titleabbrev.markup"/>
    </fo:basic-link>
    <fo:leader leader-pattern="space"/>
    <fo:basic-link internal-destination="{$id}">
        <fo:page-number-citation ref-id="{$id}" />
    </fo:basic-link>
</fo:block>

Line 1: last-line-end-indent – shifts the right block boundary to leave space between overflowing text and the right margin. text-align – sets the alignment. The attribute text-align-last is particularly important for filling the line area with fo:leader.
Line 5: the leader element, using whitespace here.

Note that this makes the text area narrower. This helps prevent the reader’s eye from accidentally following the wrong line.

  

back to top