I'm trying to diagram an exam for an educational purpose. I'm using the package multicols
to display questions in two columns. Each question of this exam is divided in three blocks:
- base text
- wording
- answers
I've grouped each of these blocks, separately, in a minipage, so they can be unbreakable. We want these blocks to be able to span columns on the same page but we're struggling to discover how to prevent one question being divided in two pages.
Here is an example:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[left=15mm,right=15mm,top=15mm,bottom=15mm]{geometry}
\usepackage[portuguese]{babel}
\usepackage{multicol}
\usepackage{blindtext}
\begin{document}
\begin{multicols*}{2}
\begin{minipage}{0.48\textwidth}
\noindent{\bf QUESTION 1}\\
\textbf{BASE-TEXT}\\
\blindtext
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\textbf{WORDING}\\
\blindtext
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\textbf{ANSWERS}\\
\blinditemize
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\noindent{\bf QUESTION 2}\\
\textbf{BASE-TEXT}\\
\blindtext
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\textbf{WORDING}\\
\blindtext
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\textbf{ANSWERS}\\
\blinditemize
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\noindent{\bf QUESTION 3}\\
\textbf{BASE-TEXT}\\
\blindtext
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\textbf{WORDING}\\
\blindtext
\end{minipage}
\vfill
\begin{minipage}{0.48\textwidth}
\textbf{ANSWERS}\\
\blinditemize
\end{minipage}
\end{multicols*}
\end{document}
If you compile this code, you will note that the blocks of question 2 are spanned in the two columns, which is desirable (column constraint), but question 3 was broken in two pages (page constraint), which we cannot let happen.
We tried to use \samepage
, which has no effect.
We tried also to add a \nobreak
after first and second block. We haven't added a \nobreak
after the third block since we do not want to inhibit a break at this point. This attempt holds page constraint, but broke column constraint, once every question was placed entirely in a column.
Is there a way to hold these two constraints at the same time in LaTeX?
Very best regards.
\goodbreak
between your question blocks, which, regardless of setting of\widowpenalty
and\clubpenalty
, which might be relevant here, yielded each question block spread over an entire column, which is suboptimal.left
=right
=top
=bottom
as options togeometry
, you can usemargin
instead of calling all four options.