I'm writing a little exam generation package in R that takes a list of questions, randomizes question order and responses, and creates a .pdf. One issue I have is that questions and their responses may be separated by a page break, which is obviously not ideal. I've found a manual workaround in encapsulating each \item within a minipage, but a manual solution won't work here.
Is it possible to modify the environment of enumerate or create a custom command that puts each \item in a minipage to keep questions from being split across pages? That way, I can include the code in the preamble of the RMarkdown document that generates the exam.
Essentially I want
\documentclass{article}
\begin{document}
\begin{enumerate}
\item
Which bear is best?
A. Honey bear\\
B. Grizzly bear\\
C. Black bear\\
D. Teddy bear\\
E. Polar bear\\
\item
How much snow per year is the preferable amount?
A. 90 inches\\
B. 120+ inches\\
C. 30 inches\\
D. 60 inches\\
\end{enumerate}
\end{document}
to become
\documentclass{article}
\begin{document}
\begin{enumerate}
\begin{minipage}{\linewidth}
\item
Which bear is best?
A. Honey bear\\
B. Grizzly bear\\
C. Black bear\\
D. Teddy bear\\
E. Polar bear\\
\end{minipage}
\begin{minipage}{\linewidth}
\item
How much snow per year is the preferable amount?
A. 90 inches\\
B. 120+ inches\\
C. 30 inches\\
D. 60 inches\\
\end{minipage}
\end{enumerate}
\end{document}
by putting something in the preamble.


