[Tex/LaTex] Turn advise on page in exam

page-breaking

I like to have a "turn page around" advise on an exam sheet because it continues. Right now, I do it manually. I need to search where the page ends and put a

\vspace*{0.5cm}
\hfill \textit{Please turn \(\hookrightarrow\)}

at the appropriate position. This is not a very neat solution, since the space needed to be adopted so that it doesn't fall onto the next page. And if I would have to do this twice or more, the vertical position should always be the same. Is there a way to achieve this automatically? Here's a minimal working example to play with.

\documentclass{minimal}
\usepackage[english]{babel}
\usepackage{blindtext}

\begin{document}

\begin{enumerate}
\item[\textbf{Task 1}]

\blindtext[5]

\item[\textbf{Task 2}]

\blindtext[3]

\vspace*{0.1cm}
\hfill \textit{Bitte wenden \(\hookrightarrow\)}

\item[\textbf{Task 3}]

\blindtext[2]

\end{enumerate}

\end{document}

Best Answer

The exam class offers precisely this functionality: for instance, you can write

\documentclass{exam}

\pagestyle{headandfoot}

\runningfooter{}{}{%
  \oddeven{\iflastpage{}{\textbf{Turn over}}}{}
}

to put an instruction to turn over only on the right-hand side of double-page spreads, but not on the very last page of the document.

If you want to implement this yourself, you could look at how exam does it, but frankly it's such a useful class for this sort of thing that I would suggest you use it unless you have a pressing reason not to do so.

(Edited to add: if you do want to do this without changing your class, the only bit not in the fancyhdr package is the \iflastpage macro, which is reasonably easy to pull out:

\makeatletter
\AtEndDocument{%
  \immediate\write\@mainaux
  {\string\gdef\string\mydoc@lastpage{\arabic{page}}}}

\def\iflastpage#1#2{%
  \@ifundefined{mydoc@lastpage}{\def\@@lastpage{-1}}%
          {\edef\@@lastpage{\mydoc@lastpage}}%
  \ifnum\value{page}=\@@lastpage\relax
    #1%
  \else
    #2%
  \fi
}
\makeatother

With this in your preamble you could use

\usepackage{fancyhdr}
\fancyfoot{} % clear everything
\fancyfoot[RO]{\iflastpage{}{\textbf{Turn over}}}

to get something like the effect you're after.)