Continuous Page Numbering

Post here questions and problems related to editing and publishing DITA content.
jmorales
Posts: 93
Joined: Tue Oct 30, 2018 9:47 pm

Continuous Page Numbering

Post by jmorales »

Hi,
We're customizing the CSS for the table of contents for PDF output, and I notice that the page numbering is not working how we would like. We want the pages in the book to be numbered continuously from the title page to the end. So our page footers throughout the book use the following for the page number:
@bottom-right { content: "Page " counter(page) " of " counter(pages);
Using this scheme, the first page of the first chapter is counted as page 4, because the Title page is on page 1, copyright is page 2, and TOC is page 3. But in the TOC, the entry for the first chapter says that the chapter starts on page 1, apparently because the front matter is not being included in the count. Is there some way to get the TOC to display the same page numbers that we're displaying on the page footers?
Thanks!
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Continuous Page Numbering

Post by Dan »

The page numbers are reset to one in two cases:
  • On the first topic that follows the TOC
  • On the first topic from the index
To avoid the page counter being reset, you can use in your customization:

Code: Select all

*[class ~= "map/map"] > *[class ~= "toc/toc"] + *[class ~= "topic/topic"],
*[class ~= "index/groups"] {
  counter-reset: none;
}
The index page also changes the format of the page numbers to lower alpha. To switch to decimal, use:

Code: Select all

@page index {
  @bottom-center {
    content: counter(page, decimal)
  }
}
jmorales
Posts: 93
Joined: Tue Oct 30, 2018 9:47 pm

Re: Continuous Page Numbering

Post by jmorales »

Thanks, Dan. That solution worked perfectly for me.
Post Reply