8

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:

  1. base text
  2. wording
  3. 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.

3
  • I've tried \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. – Ulrich Schwarz Jun 17 '13 at 18:48
  • Thanks a lot for your attempt Ulrich! I didn't know \goodbreak, \widowpenalty and \clubpenalty. Good to know that they exist. They can deal with column constraint, but unfortunately the penalty does not avoid the breaking of question 3 in two pages (page constraint). There must be a way to do this (I hope so). Best regards – emanuel_vianna Jun 17 '13 at 19:32
  • Comment: If you have left = right = top = bottom as options to geometry, you can use margin instead of calling all four options. – Svend Tveskæg Aug 21 '13 at 9:43
7

It's probably easier to use standard twocolumn for this rather than multicol as the global balancing makes it harder to know which column you are in.

enter image description here

\documentclass[a4paper,twocolumn]{article}

\usepackage[utf8]{inputenc}
\usepackage[left=15mm,right=15mm,top=15mm,bottom=15mm]{geometry}
\usepackage[portuguese]{babel}
\raggedbottom

\usepackage{blindtext}
\setlength\parindent{0pt}

\makeatletter

\def\hmm{\par\if@firstcolumn\else \par \nopagebreak \fi\par\bigskip}

\makeatother

\begin{document}



\begin{minipage}{\columnwidth}
\textbf{QUESTION 1}\\
\textbf{BASE-TEXT}\\
\blindtext
\end{minipage}
\hmm
\begin{minipage}{\columnwidth}
\textbf{WORDING}\\
\blindtext
\end{minipage}
\hmm
\begin{minipage}{\columnwidth}
\textbf{ANSWERS}\\
\blinditemize
\end{minipage}

\vfill

\begin{minipage}{\columnwidth}
\textbf{QUESTION 2}\\
\textbf{BASE-TEXT}\\
\blindtext
\end{minipage}
\hmm
\begin{minipage}{\columnwidth}
\textbf{WORDING}\\
\blindtext
\end{minipage}
\hmm
\begin{minipage}{\columnwidth}
\textbf{ANSWERS}\\
\blinditemize
\end{minipage}

\vfill

\begin{minipage}{\columnwidth}
\textbf{QUESTION 3}\\
\textbf{BASE-TEXT}\\
\blindtext
\end{minipage}
\hmm
\begin{minipage}{\columnwidth}
\textbf{WORDING}\\
\blindtext
\end{minipage}
\hmm
\begin{minipage}{\columnwidth}
\textbf{ANSWERS}\\
\blinditemize
\end{minipage}


\end{document}
1
  • I knew that there was a way to do it! I am very grateful for your attention David. Very best regards! – emanuel_vianna Jun 17 '13 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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