LaTeX forum ⇒ Document Classes ⇒ How do I keep exam choice options together on the same page?

Information and discussion about specific document classes and how to create your own document classes.
87234asdffdd
Posts: 7
Joined: Mon Jul 06, 2015 4:46 pm

Re: How do I keep exam choice options together on the same p

cgnieder wrote:For keeping the question and the possible answers together the logical idea would be to wrap the {minipage} around both

I did something different that seems to work. There are two problems, and here are the solutions:
• The question can be separated from the answers by a page break. SOLUTION: a \nopagebreak before the {minipage} as below.
• Multi-line questions can be broken up across pages. SOLUTION: define "widow penalties", assuming questions aren't more than 2 lines long. SOLUTION: wrap the question with a {minipage}. Either way, keeping an entire paragraph on the same page is a tricky thing to pull off in LaTeX, as discussed at http://www.tex.ac.uk/FAQ-nopagebrk.html.

\question[\half]{What is the airspeed velocity of an unladen swallow?} \nopagebreak\noindent\begin{minipage}[]{\linewidth}\begin{checkboxes}{} \choice 10 m/s \CorrectChoice What do you mean? African or European swallow? \choice 8 m/s \choice 12 m/s \end{checkboxes}\end{minipage}{}

Tags:

fuhrmanator
Posts: 1
Joined: Tue Apr 10, 2018 11:22 pm
LavaTyper wrote:1. How do I keep exam choice options together on the same page?

I'm late to this party, but finally found an old-school (from Knuth himself!) solution that suited me in my context: http://www.tex.ac.uk/FAQ-nopagebrk.html

Yet another trick by Knuth is useful if you have a sequence of small blocks of text that need, individually, to be kept on their own page. Insert the command \filbreak before each small block, and the effect is achieved.

In my cases, I put a \filbreak before each \question,


but you could probably put it before the answers if you're OK with a break happening between the question and the answers.