Quantcast
Channel: Reacting to a page break in LaTeX - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Werner for Reacting to a page break in LaTeX

$
0
0

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:

enter image description here

\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.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>