Re: [xsl] FO: Alphabetical index layout problem with justified last line

Subject: Re: [xsl] FO: Alphabetical index layout problem with justified last line
From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 3 Jun 2015 18:39:51 -0000
I have needed to do exactly what you state, on short and long lines:

At 2015-06-03 14:32 +0000, Michael MC<ller-Hillebrand mmh@xxxxxxxxx wrote:
We are challenged with a layout for an
alphabetical index that uses leader dots and
forces page numbers to the right border of the current column, like this:

| keyword .......... 23 |
...
What we (think we) want is nicely right-aligned
numbers (and if possible a continuation of the leader line):

| other keyword ....    |
| ....... 5, 11, 25, 42 |

... and I've accomplished that with the following standard XSL-FO:


<?xml version="1.0" encoding="US-ASCII"?><!--dual leaders.fo-->
<root xmlns="http://www.w3.org/1999/XSL/Format";
      font-family="Times" font-size="20pt">

  <layout-master-set>
    <simple-page-master master-name="frame"
                        page-height="297mm" page-width="210mm"
                        margin-top="15mm" margin-bottom="15mm"
                        margin-left="15mm" margin-right="125mm">
      <region-body region-name="frame-body" background-color="#dddddd"/>
    </simple-page-master>
  </layout-master-set>

  <page-sequence master-reference="frame">
    <flow flow-name="frame-body" xmlns="http://www.w3.org/1999/XSL/Format";>
      <block>This is a test</block>
      <block space-before="1em"
text-align="justify" text-align-last="justify">
        <inline keep-together="always">Keyword<leader
                leader-length.optimum=".5em"
                leader-pattern="dots"/></inline><inline
                  keep-together="always"><leader
                leader-length.optimum=".5em"
                leader-pattern="dots"/>23</inline>
      </block>

      <block space-before="1em"
text-align="justify" text-align-last="justify">
        <inline keep-together="always">Other keyword<leader
                leader-length.optimum=".5em"
                leader-pattern="dots"/></inline><inline
                  keep-together="always"><leader
                leader-length.optimum=".5em"
                leader-pattern="dots"/>5, 11, 25, 42</inline>
      </block>
    </flow>
  </page-sequence>
</root>

Note that I had to be careful in the above not to
introduce any white-space between the
constructs.  The constructs are identical and can
be used in XSLT template rules, the content of
the left and right bits is arbitrary.  You can
use any construct to create the list of page numbers.

My choice of the optimum size of .5em for the
leader results in one line being used when the
space between the text and the first page number
is at least 1em, but if it is less than 1em, two lines are used.

My client was producing a catalogue of titles and
the list of associated contract numbers and needed this presentation.

The principle is that in a justified line, all
elastic leaders are stretched to fill the line,
so I keep together an elastic leader with the
text on the left and another elastic leader with
the text on the right.  When they both fit on one line, both leaders grow.

I hope this helps.

. . . . . . . . Ken

At 2015-06-03 14:32 +0000, Michael MC<ller-Hillebrand mmh@xxxxxxxxx wrote:
Hello experts,

We are challenged with a layout for an
alphabetical index that uses leader dots and
forces page numbers to the right border of the current column, like this:

| keyword .......... 23 |

If the keyword gets longer and suffers a line break, everything is fine:

| a special, longer     |
| keyword .......... 23 |

But, if we have many page references, so that
both keyword and all page numbers do not fit a
single line, it gets ugly, e.g. like this:

| other keyword .... 5, |
| 11,      25,       42 |

If we were using non-breaking spaces between entries, we may get this:

| other keyword         |
| 5,   11,    25,    42 |

What we (think we) want is nicely right-aligned
numbers (and if possible a continuation of the leader line):

| other keyword ....    |
| ....... 5, 11, 25, 42 |

This is the FO we are working with at the moment
(some attributes removed and pretty printing added):

<fo:block text-align-last="justify"
end-indent="6mm" last-line-end-indent="-6mm">other keyword
  <fo:leader/>
  <fo:basic-link
internal-destination="d85e73"><fo:page-number-citation
ref-id="d85e73"/></fo:basic-link>,
  <fo:basic-link
internal-destination="d85e160"><fo:page-number-citation
ref-id="d85e160"/></fo:basic-link>,
  <fo:basic-link
internal-destination="d85e354"><fo:page-number-citation
ref-id="d85e354"/></fo:basic-link>,
  <fo:basic-link
internal-destination="d85e543"><fo:page-number-citation
ref-id="d85e543"/></fo:basic-link>
</fo:block>

As always, I am grateful for any suggestions or
pointers. Like, should we work with
<fo:index-page-citation-list> instead, to solve this problem?

Thanks,


--
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Free 5-hour lecture:  http://www.CraneSoftwrights.com/links/video.htm |
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile:       http://plus.google.com/+GKenHolman-Crane/about |
Legal business disclaimers:     http://www.CraneSoftwrights.com/legal |


--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Current Thread