[texhax] Suppressing pagebreak after a list

Steve Schwartz s.schwartz at imperial.ac.uk
Fri Apr 11 02:08:23 CEST 2008

Dear All,

Thanks to this forum, I found Paul Taylor's \pushright solution which
puts a qed square flush right on a line (or flushright on the next line
if there's not enough room). This was easy to modify for use in an exam
class that assigns marks to questions. It sets widowpenalties to 10000
to ensure that a pagebreak doesn't separate the theorem from the square.

I've now hit something similar but worse. At the end of each question, I
calculate the total marks which likewise goes flushright (again I use
pushright to do this). However, the class sets up newenvironments for
questions and subquestions. The subquestions are a simple list. The
questions are essentially items of a list, but set up things in the
\begin{question} like zeroing the marks, re-setting equation numbers to
zero, setting footer information, etc. And the \end{question} then puts
the total marks on a line, modifies the footer, and other things before
throwing a page and moving to the next question.

My problem is that I can't suppress a pagebreak before the total marks,
I think because the end of the subquestion list is always identified by
latex as a good pagebreak location. 

Here's what my code looks like:

     \item How much is 2+2?  \qmarks{3}
     \item How much is 4+4?  \qmarks{4}
       % this generates a line:  [Total 7 marks] using pushright

Here's the structure of my question and subquestion environments
(stripped down slightly and without definitions of my counters and

  { \setcounter{nmarks}{0}
    % etc.
    \markboth{\textit{[This question continues overleaf \ldots]}}{}%
{\pushright{\sffamily[Total~\arabic{nmarks}}]}  % <<<<<<<---------
   \ifthenelse{\equal{\thepage}{\pageref{icphexam at last}}}%
    {\markboth{\textbf{End of examination paper}}{}}%
    {\markboth{\textbf{Please turn over}}{}}


Is there any (simple) way to force the arrowed line to not find itself
alone on the next page?


PS Here's is the pushright material in case you want to see it:

%  based on P. Taylor macro
\def\pushright#1{{%        set up
    \parfillskip=0pt            % so \par doesnt push \square to left
    \widowpenalty=10000         % so we dont break the page before
    \displaywidowpenalty=10000  % ditto
    \finalhyphendemerits=0      % TeXbook exercise 14.32
   %                 horizontal
    \leavevmode                 % \nobreak means lines not pages
    \unskip                     % remove previous space or glue
    \nobreak                    % dont break lines
    \hfil                       % ragged right if we spill over
    \penalty50                  % discouragement to do so
    \hskip.2em                  % ensure some space
    \null                       % anchor following \hfill
    \hfill                      % push \square to right
    {#1}                        % the end-of-proof mark (or whatever)
   %                   vertical
    \par}}                      % build paragraph

Professor Steven J Schwartz      Phone: +44-(0)20-7594-7660
Space and Atmospheric Physics    Fax:   +44-(0)20-7594-7772
The Blackett Laboratory          E-mail: s.schwartz at imperial.ac.uk
Imperial College London          Office: Huxley 6M70 
London SW7 2BW, U.K.             Web: http://www.sp.ph.ic.ac.uk/~sjs

More information about the texhax mailing list