# resetting page number with \pageref

I have a big book (about 2500 pages) in a single latex file, with a lot of cross references. The book contains 3 volumes in succession, each with a table of contents, an introduction, etc. At the beginning of each volume, the commands \frontmatter and \mainmatter are used to obtain Roman page numbering. My problem is that this resets the normal page number to 1, which creates problems (for instance make the index of the whole thing useless).

I can insert \setcounter{page}{1595} where needed for instance, but if I change anything in the previous pages, this 1595 should automatically change. Then I tried:

\setcounter{page}{\pageref{Volume-II}}


after, of course, inserting a \label{Volume-II} at the right place. This does not work. Can I reset the page number counter with a label? Apologies if the question is trivial, and thanks in advance!

Franck

• Since \pageref returns more that just the number, that will not work. Do you mind providing a small example of how you split everything up? Say give each volume a page or two, and make sure the MWE is self contained. Then it is a lot easier to give advise, since we'll also know which document class you use (perhaps it has got something smart to use). BTW you may get away with the \setcounterref from the refcounter package, see this answer: tex.stackexchange.com/a/120203/3929 – daleif Jul 11 '18 at 13:23
• Thanks. Thanks also for the information about the refcounter package. My question was trivial, and David Carlisle provided a simple solution. The book in in the book style. Making a MWE from the existing files would be a lot of work, because the preamble file is now enormous, with changes of styles for the chapters, the complements, the appendices. But never mind, I now have the solution to my problem. Thanks again. Franck – Franck Jul 11 '18 at 14:53

Your question is very unclear but if you have in your preamble

\newcounter{zzz}


then

\cleardoublepage
\setcounter{zzz}{\value{page}}
\mainmatter
\setcounter{page}{\value{zzz}}


will do \mainmatter without changing the page counter.

• Sorry for the very unclear question, but fortunately your answer is perfectly clear. It works perfectly well. I am grateful.. and now I realize that my question was indeed trivial. – Franck Jul 11 '18 at 14:51

You can use the \setcounterpageref command from the refcount package. Specifically,

\setcounterpageref{page}{Volume-II}


will set the page number equal to the page number for the label Volume-II. In the MWE below the page number will keep on growing each time you compile as the label is set on the last page.

\documentclass{book}

\usepackage{refcount}

\begin{document}
\setcounterpageref{page}{Volume-II}
\chapter{Fake chapter}
\chapter{Fake chapter}
\chapter{Fake chapter}
\chapter{Fake chapter}
\chapter{Fake chapter}
\label{Volume-II}
\end{document}


Btw, for your own oanity I would recommend breaking your multi-volume document up into smaller files. You can use the xr package to add cross references to labels defined in different files.

• Thank you for this suggestion, which looks very simple and efficient. I already used David Carlisle's suggestion, which also works perfectly well. Your recommendation about smaller files is excellent: I actually have about 200 different files, saved on a NAS and a separate USB key. – Franck Jul 11 '18 at 15:01