1

We are using this XSL-FO to generate entries in the Table of Contents page:

<fo:block text-align-last="justify">
    <xsl:value-of select="@title" />
    <fo:leader leader-pattern="dots" />
    <fo:page-number-citation ref-id="{@id}" />
</fo:block>

When pages have very long titles, the page number is bumped onto a new line. If the page title is long enough to bump the page number onto a new line but not long enough to go onto a new line itself, the page number will be left aligned when it should be right aligned.

As far as I can tell, the XML is correct and this is an issue with XSL-FO itself. Is there a way to get all of the page numbers right aligned without redesigning anything else about the layout?

image of table of contents where the page titles have different lengths and the middle length has a left-aligned page number

Update:

Thanks for the response Tony Graham, unfortunately it doesn't seem for me for some reason. On lines that should have a single continuous leader I would end up with two sets of leader dots separated by a small gap that I could not get rid of. But it did inspire this solution that works well enough for me:

<fo:block text-align-last="justify">
    <xsl:value-of select="@title" />
    <fo:leader leader-pattern="dots" />
    <fo:page-number-citation keep-with-previous="always" ref-id="{@id}" />
</fo:block>
  • 1
    Which software are you using to generated to PDF? If you're using Antenna House Formatter, it has extensions to handle this case : https://www.docs.antennahouse.com/formatter/ahf-ext.html#axf.leader-expansion – potame Jun 15 '20 at 08:06
  • It will not possible to resolve this case unless formatter you are using supports forcing fo:leader to expanse unconditionally such like above example page. – Toshihiko Makita Jun 15 '20 at 08:42

1 Answers1

2

You essentially have examples 1, 3, and 5 from the axf:leader-expansion documentation at https://www.antenna.co.jp/AHF/help/v70e/ahf-ext.html#axf.leader-expansion

As others have pointed out, you can't handle every possible ToC or index variant with vanilla XSL-FO, but you can achieve a result for the sample that you showed:

<fo:flow flow-name="xsl-region-body"
     leader-alignment="reference-area"
     text-align-last="justify">
  <fo:block>Page with very short title<fo:leader leader-pattern="dots" keep-with-previous.within-line="always" /><fo:leader leader-pattern="dots" />3</fo:block>
  <fo:block>Page with very very very very very very very very long title<fo:leader leader-pattern="dots" keep-with-previous.within-line="always" /><fo:leader leader-pattern="dots" />4</fo:block>
  <fo:block>Page with very very very very very very very very very very very very long title<fo:leader leader-pattern="dots" keep-with-previous.within-line="always" /><fo:leader leader-pattern="dots" />5</fo:block>
</fo:flow>

Formatted ToC

Tested with AH Formatter V7.0.

Tony Graham
  • 7,306
  • 13
  • 20