Continuous Page Numbering

jmorales
Posts: 45
Joined: Tue Oct 30, 2018 9:47 pm

Continuous Page Numbering

Post by jmorales » Thu Oct 24, 2019 7:32 am

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: 438
Joined: Mon Feb 03, 2003 10:56 am

Continuous Page Numbering

Post by Dan » Fri Oct 25, 2019 3:33 pm

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: 45
Joined: Tue Oct 30, 2018 9:47 pm

Re: Continuous Page Numbering

Post by jmorales » Tue Nov 05, 2019 7:29 am

Thanks, Dan. That solution worked perfectly for me.

Post Reply