I'm building a set of 6 PDF books in LaTeX, and I'd like the page numbers to monotonically increase throughout the series. For example, Book 1's last page number is 341, so Book 2's first page number should be 342. Each book has its own set of .tex files which compiles into its own PDF.

How can I ensure the page numbers increase across these separate .tex files?

Perhaps I could use the xr package (example) to reference the preceding book's \pageref{LastPage} (example)?


1 Answer 1


Since the page numbering restarts at \mainmatter, you need to keep the main matter in separate files from the \frontmatter (and avoid \backmatter). Your master file uses \includeonly to select which book to print. Here the first book is in test5.tex and the second is in test6.tex.

There was a slight problem in that the first book ended on an odd page, so the extra page before the chapter wound up in the second book.


\includeonly{test6}% select one at a time

where test5.tex contains

\chapter{First Chapter Book1}
First book starts on \thepage

and test6.tex contains

\chapter{First Chapter Book 2}
Second book starts on \thepage

So how do you want the chapters numbered and the table of contents divided (easiest would be to make each book a part and possibly redefine \partname)?


  • This is a nice solution. Is there a way to generate both books with one command? It seems that the main tex file can either be configured to produce one book or the other. Commented Dec 16, 2016 at 13:34
  • Only one PDF per LaTeX run (externalize counts as an extra run). Commented Dec 16, 2016 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .