Advertisement
Guest User

Reacting to page breaks

a guest
Jun 29th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 1.15 KB | None | 0 0
  1. \documentclass{article}
  2.  
  3. \usepackage{lipsum}
  4. \usepackage{refcount}
  5.  
  6. \makeatletter
  7.  
  8. \newcommand \@@footer{%
  9.   \ifnum\getpagerefnumber{question-start-\thequestion}<\getpagerefnumber{question-end-\thequestion}
  10.    Question~\thequestion{} continues on the next page%
  11.   \fi\hfill\parbox[c]{5cm}{\Large\bf \flushright SEE NEXT PAGE}}
  12.  
  13. \def \ps@exam{%
  14.     \let \@mkboth \@gobbletwo%
  15.     \def \@oddhead{}%
  16.     \def \@oddfoot{\@@footer}%
  17.     \def \@evenhead{}%
  18.     \def \@evenfoot{\@@footer}%
  19. }
  20. \pagestyle{exam}
  21.  
  22. \newcommand \testpagebreak[1]{%
  23.     \vfil%
  24.     \penalty #1%
  25.     \vfilneg%
  26. }
  27.  
  28. \newcounter{question}
  29.  
  30. \newenvironment{question}{%
  31.   \begin{list}{}{}%
  32.     \refstepcounter{question}%
  33.     \item[\bfseries\thequestion.]%
  34.     \leavevmode% Start paragraph
  35.     \label{question-start-\thequestion}%
  36. }{%
  37.     \label{question-end-\thequestion}%
  38.     \end{list}%
  39.     \testpagebreak{-350}%
  40. }
  41.  
  42.  
  43. \begin{document}
  44.  
  45.  \begin{question}
  46.    \lipsum[1-7]
  47.  \end{question}
  48.  
  49.  \begin{question}
  50.     \lipsum[8-10]
  51.     %\lipsum[8-13]
  52.   \end{question}
  53.  
  54.  \begin{question}
  55.    Just a single line
  56.  
  57.    And another
  58.  \end{question}
  59. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement