[Tex/LaTex] How to adjust the total page count variable

exampage-numbering

If I have a page count of 7, but the last page is a grading sheet (using the exam class). I do not actually want it to be counted as part of the exam, although I need one copy per printout. The variable \numpagescontains the number 7, but I want to make it 6, such that the students read Side 1 of 6 etc. in the footer. Is there a way to make a formula that does something like:

\renewcommand{\numpages}{\numpages - 1}

?

Most questions involving page numbers seem to simply reset the counter after a few pages (using \setcounter{page}{1}), such that there is a new page one. In this case, that would not work.

Best Answer

\numpages in the exam document class is defined as

\def\numpages{\@ifundefined{exam@lastpage}%
  {\mbox{\normalfont\bf ??}}%
  \exam@lastpage
}% numpages

So, one could redefine it as follows

\def\numpages{\@ifundefined{exam@lastpage}%
  {\mbox{\normalfont\bf ??}}%
  \the\numexpr\exam@lastpage-1\relax
}% numpages

Note that this redefinition requires the use of a \makeatletter...\makeatother pair. See What do \makeatletter and \makeatother do?