What about the following idea?
It's much different from yours (or perhaps the class author's), but perhaps more robust as it uses the \label
-\ref
system to determine whether a page break has occurred mid-question:
\documentclass{article}\usepackage[paper=a5paper,margin=1in]{geometry}% Just for this example\usepackage{multido}% Just for this example\usepackage[nopar]{lipsum}% Just for this example\usepackage{refcount}\usepackage{fancyhdr}\newcounter{question}\newenvironment{question}{% \begin{list}{}{}% \refstepcounter{question}% \item[\bfseries\thequestion.]% \leavevmode% Start paragraph \label{question-start-\thequestion}% }{% \label{question-end-\thequestion}% \end{list} }\pagestyle{fancy}\fancyhf{}% Clear header/footer\fancyfoot[L]{% Left footer \ifnum\getpagerefnumber{question-start-\thequestion}<\getpagerefnumber{question-end-\thequestion} Question~\thequestion{} continues on the next page% \fi}\fancyfoot[R]{See next page}% Right footer\renewcommand{\headrulewidth}{0pt}% Remove header rule\AtEndDocument{\fancyfoot[R]{}}% Remove right footer at end of document\sloppypar% Just for this example\begin{document}\multido{\i=1+1}{50}{% \begin{question} \lipsum[\i] \end{question} \bigskip}\end{document}
At each \item
inside question
, a \label
is set, and then another \label
at the end of the question
. A check is made to see whether the page number at the start is different from (less than) the ending page number. Accordingly, the footer sets the appropriate clause.