1

I am using the exam package as follows:

\documentclass[answers, addpoints]{exam}
\usepackage{lipsum}  
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy} 
\begin{document}
%\includepdf{frontpage.pdf}
\begin{questions}

\question

\lipsum[1-10]

\end{questions}

\end{document}

I have two problems.

  • I tried to add page # of ## using the method described at this answer but the packages needed seem to conflict. I get

Command \lhead already defined. ...ef\f@nch@olh{#2}\f@nch@def\f@nch@elh{#1}}

  • My second problem is that I want page 1 of ## to be on the front page. The includepdf line should include the front page so it would need to be overwritten on that page.
Simd
  • 6,785

1 Answers1

2

For the first part, the exam class already defines header and footer. That is why it clashes with fancyhdr. Also, it defines the command \numpages so you don't need the lastpage package.

Have a look at chapter 11 of the examdoc for header and footer. Here I added the page # of ## as the right foot with \rfoot{page \thepage{} of \numpages}

To add this footer to your frontpage, have a look at this answer. When you use \includepdf, add the optional argument pagecommand={\pagestyle{headandfoot}}. i used it with headandfoot style, but you could use others.

\documentclass[answers, addpoints]{exam}
\usepackage{lipsum}  
\usepackage{pdfpages}
\footer{}
    {page \thepage{} of \numpages}
    {}
\pagestyle{headandfoot}

\begin{document} \includepdf[pages=-,pagecommand={\pagestyle{headandfoot}}]{frontpage.pdf} \begin{questions}

\question

\lipsum[1-10]

\end{questions}

\end{document}

  • This has both page # in the bottom middle and also page # of ## in the bottom right. I would like to have only page # of ## and for that to be in the bottom middle. – Simd Nov 16 '23 at 12:04
  • 1
    I focused on adding page # of ## and I didn't clear the footer. I'll update my answer. – Alain Remillard Nov 16 '23 at 17:46