7

I am using the exam class.

I am writing an exam, and I want the last footer (the final, last one to appear) to be "End of exam".

I have this:

    \pagestyle{headandfoot}
    \runningheadrule
    \firstpageheader{AP Calculus Practice Exam A1}{ Mao Laoshi }{Senior 2}
    \firstpageheadrule
    \runningheader{AP Calculus Practice Exam A1}
    { Page \thepage\ of \numpages}
    {Senior 2 }

    \footer{}
    {\iflastpage{End of exam}{Please go on to the next page\ldots}}
    {}
  • 1
    It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. – Peter Grill Nov 8 '12 at 3:10
9

You can use

\iflastpage{<text 1>}{<text 2>}

inside \footer. <text 1> will be used in the last page, and <text 2> will be used in all other pages, except the last one; a simple example, now including the settings of the edited question:

\documentclass{exam}
\usepackage[paperheight=12cm]{geometry}% just for the example
\usepackage{lipsum}% just to generate filler text for the example

\pagestyle{headandfoot}
\runningheadrule
\firstpageheader{AP Calculus Practice Exam A1}{ Mao Laoshi }{Senior 2}
\firstpageheadrule
\runningheader{AP Calculus Practice Exam A1}
{Page \thepage\ of \numpages}
{Senior 2}
\footer{}
{\iflastpage{End of exam}{Please go on to the next page\ldots}}
{}

\begin{document}
\lipsum[1-7]
\end{document}

enter image description here

  • the \lipsum[1-30] do I have to know how many pages before the end? – MaoYiyi Nov 8 '12 at 3:20
  • 1
    @MaoYiyi no; \lipsum[30] only generates some pages with "dummy" text and you don't have to use it in your actual document; \iflastpage automatically will detect the last page. – Gonzalo Medina Nov 8 '12 at 3:21
  • @MaoYiyi in your document all you need to add is something like \footer{} {\iflastpage{End of exam}{Please go on to the next page\ldots}} {} in the preamble. – Gonzalo Medina Nov 8 '12 at 3:24
  • Your solutoin gave me a runaway footer issue, but answer below worked? I have none idea why. – MaoYiyi Nov 8 '12 at 4:19
  • @MaoYiyi did you try the exact code I posted? Did you get the error with that code or with your actual code? – Gonzalo Medina Nov 8 '12 at 4:21
2

One can also achieve the same result with the command \runningfooter{<text>}{<text>}{<text>}:

\runningfooter{}{\iflastpage{End of exam}{Please go on to the next page\ldots}}{Page \thepage\ of \numpages}

This allows the first page footer to be different from the rest of the pages:

\firstpagefooter{}{}{Page \thepage\ of \numpages}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.