I use the exam class to write multiple choice questions, and I frequently use tikz to make a diagram that precedes a question. How can I make sure that each diagram+question doesn't break across a column or page break?
Wrapping the tikzpicture and question in a minipage works for the 2nd question onward, but not for the very first question after \begin{questions}. Is there a way I can do something similar for the first question?
This works:
\documentclass[twocolumn]{exam}
\usepackage{tikz}
\begin{document}
\twocolumn
\begin{questions}
\question What's the length of the line above?
\begin{choices}
\choice 1
\choice 8
\end{choices}
\begin{minipage}{\linewidth}
\begin{tikzpicture}
\draw (0,0) -- (2,0);
\end{tikzpicture}
\question What's the length of the line above?
\begin{choices}
\choice 2
\choice 1
\end{choices}
\end{minipage}
\end{questions}
\end{document}
But this doesn't compile (presumably since \begin{questions} expects \question right away):
\documentclass[twocolumn]{exam}
\usepackage{tikz}
\begin{document}
\twocolumn
\begin{questions}
\begin{minipage}{\linewidth}
\begin{tikzpicture}
\draw (0,0) -- (2,0);
\end{tikzpicture}
\question What's the length of the line above?
\begin{choices}
\choice 2
\choice 1
\end{choices}
\end{minipage}
\question What's the length of the line above?
\begin{choices}
\choice 1
\choice 8
\end{choices}
\end{questions}
\end{document}