# How do I have two sets of page numbers in a document?

I want to have two sets of page numbers (P and p) in my document. The first one (P) is global, the second one (p) resets to 1 at some predefined points.

So, the document will look like,

Text

P1/5 p1/3

Text

P2/5 p2/3

Text

P3/5 p3/3

Text. In this page the page number (p, second one) is reset.

P4/5 p1/2

Text

P5/5 p2/2

To get the total page count a label in the last page or the lastpage package (http://www.ctan.org/pkg/lastpage) can help me. And that is not the subject of this question.

The problem is with the second counter. I can use chappg (http://www.ctan.org/pkg/chappg) with noauto option. But I loose the global page counter P. Moreover, the (sub) total number of pages in that group has to be manually set.

I understand that if I write a set of macros with a new counter (my@local@page), reset it at my predefined points, label the last page in a group (label names will have to be distinct), perhaps I can achieve my goal. But that requires at least half a day. Which I do not have at this moment.

I was wondering if you can suggest something readily usable.

-
What defines this group of sub-pages? Is it a chapter? A section? Also, what \documentclass are you using? Do you have any package restrictions? –  Werner Nov 13 '12 at 3:59
This is actually a list where I need to reset the page number for a new group. These points are known to me (i.e. I can manually issue a command there, but nothing automatic). These are not chapters or sections or anything like that. \documentclass is article. No package restrictions. –  Masroor Nov 13 '12 at 4:17
Is a \newpage or \clearpage issued before the command that changes the page numbering? If so, it would make things much easier. –  tohecz Nov 13 '12 at 6:53
Yes, \clearpage is always issued the changes in page numbering. –  Masroor Nov 13 '12 at 7:44
If you are ready to compile separately the separately-numbered page groups, the pdfpage package might help you. –  T. Verron Nov 13 '12 at 7:45

Here's a possible setup. I use fancyhdr for typesetting the two page numbers and also for stepping the secondary counter. The macro \resetpageaux does a \clearpage, sets a label and sets the secondary counter to zero. At the end of the document we set also the last label.

\documentclass{article}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\twopagenumbers}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[C]{\twopagenumbers}
}

\usepackage{atenddvi}
\usepackage[user]{zref}

\newcounter{pageaux}
\def\currentauxref{PAGEAUX1}
\newcommand{\twopagenumbers}{%
\stepcounter{pageaux}%
P \thepage/\zpageref{LastPage} -- p \thepageaux/\ref{\currentauxref}%
}
\makeatletter
\newcommand{\resetpageaux}{%
\clearpage
\edef\@currentlabel{\thepageaux}\label{\currentauxref}%
\xdef\currentauxref{PAGEAUX\thepage}%
\setcounter{pageaux}{0}}
\AtEndDvi{\edef\@currentlabel{\thepageaux}\label{\currentauxref}}
\makeatletter

\usepackage{kantlipsum} % just for mock text

\begin{document}

\kant

\resetpageaux

\kant[1-14]

\resetpageaux

\kant[1-22]

\end{document}


-