This question is similar to: How do I have two sets of page numbers in a document?
I have an exam class document (built on article) that contains the exam questions in a first section* and extra output/figures in a second section*. Both are in the same document in order to be able to refer to the correct labels using ref{}. Yet, both sections will be printed separately and should contain page numbers like page 3 of 12.
I use fancyhdr to get that footer correctly, but I have a problem getting the correct numpages. Now it counts only the number of pages for the last section (in this case 2). I've been playing with the solution given in the question I link to, but I was hoping there was a simpler solution.
Example :
\documentclass{exam}
\renewcommand{\maketitle}{
% Get rid of verticalmode errors from exam class
}
% From the cls file we use for the exams
\AtBeginDocument{
\pagestyle{foot}
\footer{}{Page \thepage\ / \numpages}{}
}
\usepackage{kantlipsum} % get some text
\begin{document}
You have \numpages~pages
\kant[1-14]
\clearpage
\setcounter{page}{1}
\section*{Another section}
You have \numpages~pages
\kant[1-7]
\end{document}
\resetpagecountsto get the correct result. I got things working more or less based on thezrefandatenddvitrick from the other question, but it still feels overly complicated. If you have a more concise solution that could fit in a cls, feel free to add it. – Joris Meys Jan 10 '19 at 16:21