# Suppressing page numbers in “exam” document class

I'm using the exam class like this:

\documentclass{exam}
\begin{document}
\begin{questions}
\question[1] Who's buried in Grant's tomb?
\end{questions}
\end{document}


Now I try to remove page numbers using \pagenumbering{gobble}:

\documentclass{exam}
\pagenumbering{gobble}
\begin{document}
\begin{questions}
\question[1] Who's buried in Grant's tomb?
\end{questions}
\end{document}


And I get this error:

! Missing number, treated as zero.
\relax
l.5   \question[1]
Who's buried in Grant's tomb?
A number should have been here; I inserted 0'.
(If you can't figure out why I needed to see a number,
look up weird error' in the index to The TeXbook.)

1. Why does this happen?
2. What should I do to fix it?

What should I do to fix it?

You should use either \pagestyle{empty} or \cfoot{}.

A full MWE:

\documentclass{exam}
\usepackage{lipsum} % provides filler text
\begin{document}
\pagestyle{empty}
\begin{questions}
\question[1] Who's buried in Grant's tomb?
\lipsum[1-30] % 3+ pages of filler text
\end{questions}
\end{document}


Why does this happen?

I'm not privy to the deep reasons for why the designer(s) of this document class made various design choices. All I can offer is a what is going on explanation, in terms of LaTeX code. The document class has a feature called an "incomplete question". In order to determine whether or not a given question may be incomplete, the code compares the number of the current page with the final page number of the document. If somebody -- e.g., you -- executes \pagenumbering{gobble}, no page numbers are available to carry out this comparison, and all the TeX program can do is crash with the 'weird error' exception.

• That's great, but it doesn't explain why \pagenumbering{gobble} doesn't work. – Nathaniel M. Beaver Sep 25 '17 at 20:38
• @bariumbitmap -- I've posted an addendum to address your "why" question. – Mico Sep 25 '17 at 22:08