JablJak
JablJak

Reputation: 11

Multiple page sequences and page numbers

I am using XSLT and XSL-FO for document creation.

I need to introduce multiple sequences of page numbering, i.e main section numbered from 1 to end page, which is broken by two subsequences of corresponding subdocuments, numbered from 1 to end of each of these sections, and after them the main sequence is continued.

The problem I can't overcome is that the subsequences are counted in main sequence, and page number of main section after continuation is incremented page number of previous subsequence.

So I get e.g.

main section subsection subsection continuation of main
1, 2, 3 1, 2 1, 2 3, 4, 5...

And I want

main section subsection subsection continuation of main
1, 2, 3 1, 2 1, 2 4, 5, 6...

How can I achieve it?

Upvotes: 1

Views: 620

Answers (1)

lfurini
lfurini

Reputation: 3788

In an FO file, the fo:page-sequence elements define a flat list of contents to be paginated, so there is no concept of a "main section" containing "subsections".

The initial-page-number property controls how page numbers are computed for a page sequence.
In particular, when a page sequence ends and a new one starts the only available options concerning page numbering are:

  • continue the enumeration with the next page number (optionally, the next odd one or even one)
  • restart from a specified number

There is no way to refer to a different page sequence and say "continue from that".


That said, if your document is not much more complicated than your example you can achieve what you want with a workaround.

This is probably the easiest (and dirtiest) one:

  1. create the pdf output without changing anything; note down the page number that the "continuation of main" section should start from (4, in your example)
  2. modifiy the FO file (or the XSLT), inserting initial-page-number="4" in the appropriate fo:page-sequence
  3. recreate the output file

Slightly more complicated:

  1. modify your XSLT so that it produces the fo:page-sequence elements in the order: (main section) - (continuation of main) - (subsection) - (subsection)
    there is no need to specify initial-page-number for the "continuation of main" section; for subsections, use initial-page-number="1" to restart the page numbers (but they are already like this, from your example)
  2. once you have the pdf, use some tool to move the pages around and have them in the order you desire

A cleaner and fully-automated solution would require using FOP's intermediate format:

  1. create the intermediate format output
  2. modify it to fix the page numbers as needed
  3. create the final output from the modified intermediate file

A final note: you did not specify why your document needs such a peculiar page numbering and what degree of control you have on this requirement, but I cannot help wondering whether it is confusing for a reader to see page numbers restart that way, and difficult for them to find what they need ("I am told the information I need is on page 2; but which page 2?").

Upvotes: 0

Related Questions