# How can I adjust the total page count variable?

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.

-
Can you not just put a label on the sixth page and then use \ref to get the page number as the page count? This is basically what the lastpage package does automatically for the last page. You just need to put your label on the last page you want counted and to use that in place of \numpages. I think that would be a lot simpler than trying to use \numpages minus whatever. (What if your grading sheet spills to a second page? Then you'll need to adjust the definition manually.) –  cfr Jan 9 at 1:59
Did you try out packages like lastpage or the more advanced pageslts? –  Speravir Jan 9 at 3:31
Oh I forgot: In documentation for pageslts there’s a section “Alternatives”, that you should read. Some of the packages look promising. –  Speravir Jan 9 at 3:40

\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?

-

Something like this:

\documentclass{article}
\begin{document}
Page \pageref{pg:one} of the exam\label{pg:one}.

There are \pageref{pg:examend} pages in this examination.
\clearpage
Page \pageref{pg:two} of the exam\label{pg:two}.
\clearpage
Page \pageref{pg:three} of the exam\label{pg:three}.
\clearpage
Page \pageref{pg:four} of the exam\label{pg:four}.
\clearpage
Page \pageref{pg:five} of the exam\label{pg:five}.
\clearpage
Page \pageref{pg:six} of the exam\label{pg:six}.
\label{pg:examend}
\clearpage
\end{document}


Please note that I cannot check these images have uploaded correctly as I am unable to view images on the site at the present time.

EDIT: Since you are using the exam class and want to use \numpages, you could adapt the example from the manual of headers and footers to use this as follows:

\documentclass{exam}

{First Exam, Page \thepage\ of \numpages}
{July 4, 1776}
\firstpagefooter{}{}{}
\runningfooter{}{}{}

\def\numpages{%
\pageref{pg:examend}
}% numpages

\begin{document}
\clearpage
Some more questions here.
\label{pg:examend}
\clearpage

@cfr I mean that adding \pageref all over the place is not what I had in mind. This is what I mean by "hardcoded"—writing extra code on every page. Consider an exam with 100 questions taking up many pages. Your method would require much more work than the solution provided by Werner, for example. I knew some redefinition of the numpages would be best, but my skills in this area are limited. This way, the body of my document remains untouched, yet my goal achieved! Thanks, both of you! –  macmadness86 Jan 9 at 12:03