Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How do I keep questions from splitting between pages in exam? For example in the MWE below, I'd like to have a page break after Question 2 so that Question 3 can start on a new page. I don't particularly care how this is done but I imagine a vertical fill would work. Is there a command within exam that does this? I only see the commands that specify what to do with the header/footer if there is continuation but nothing about disabling continuation.

EDIT: Is there a way to make exam do this automatically instead of having me specify where to have a page break?

\documentclass[addpoints]{exam}
\usepackage{blindtext}

\begin{document}

\begin{questions}

\question
\blindtext[3]
\begin{choices}
\choice 
\choice 
\choice 
\choice 
\choice 
\end{choices}

%

\question
\blindtext
\begin{choices}
\choice 
\choice 
\choice 
\choice 
\choice 
\end{choices}

%

\question
\blindtext
\begin{choices}
\choice 
\choice 
\choice 
\choice 
\choice 
\end{choices}

%

\end{questions}
\end{document}
share|improve this question

2 Answers 2

up vote 2 down vote accepted

The answer How to prevent page breaks in lists? ("Exam" class) by @Mico is only for protecting the choices in a multiple-choice list, not the entire question. It still allows page breaks between a question prompt and its list of options. To avoid that, just define a new environment (shown here for multiple choice):

\documentclass[%answers,
addpoints,12pt]{exam}
\boxedpoints
% \pointsinmargin % Not compatible with the minipaging of multichoice questions
\newenvironment{mcquestion}[3]{    \begin{minipage}{\linewidth}    \question[#1][#2] #3    \begin{choices}}{ \end{choices} \end{minipage}}

\begin{document}
\gradetable[h]

 \begin{questions}
\begin{mcquestion}{1}{2 min}{Foodle:}
\choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \end{mcquestion}
\begin{mcquestion}{1}{2 min}{Foodle:}
\choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \end{mcquestion}
\begin{mcquestion}{1}{2 min}{Foodle:}
\choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \choice fish A    \end{mcquestion}

\end{questions}
\end{document}

This now protects the whole question from breaking, which might be more useful to some. The problem with the above is that if I ant to use the \pointsinmargin option, they overwrite the question number.

But I'm unable to apply @Mico's code to an environment (multichoice) in the way he does. Using the following (and multichoice environment instead of mcquestion) does not compile:

\newenvironment{multichoice}[3]{
\question[#1][#2]#3
\begin{choices}}{ \end{choices} 
}
\usepackage{etoolbox}
\AtBeginEnvironment{multichoice}{%
   \par\medskip\begin{minipage}{\linewidth}}
\makeatletter
\AtEndEnvironment{multichoice}{%
   \if@correctchoice \endgroup \fi%
   \end{minipage}}
\makeatother
share|improve this answer
    
Thanks! This solves 90% of the problems. Btw, you have an errant \end{multichoice} in the code. –  ceiling cat Oct 7 at 22:30
    
Thanks @ceilingcat; errant code removed. –  CPBL Oct 8 at 2:16

It looks to me that, if all else should fail, you can wrap your question-choice blocks in

\begin{minipage}{\linewidth}
\question \dots
\end{minipage}
share|improve this answer
1  
If you do that, and use the \pointsinmargin feature, the points boxes overwrite the question numbers. –  CPBL Oct 6 at 20:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.