1

I'm using \vspace{\fill} to even space out questions of an exam, but the length changes from page to page. I want the same space after every question, and the last question to be at the end of the last page (but for that question to have the same \fill space after it). I'm using multicol too, so I'd like the last column to not be empty.

Here's a MWE:

\documentclass[12pt]{exam}
\usepackage{enumitem, multicol}

\begin{document}
\large
\begin{multicols*}{2}
\begin{questions}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}

\end{questions}
\end{multicols*}
\end{document}
3
  • If you want to align the questions, use a 1 2// 3 4// 5 6 scheme using paracol. Jun 9, 2021 at 16:38
  • Perhaps I'm misunderstanding something, but unless every question occupies exactly the same amount of space, what you're asking is impossible. Jun 9, 2021 at 20:11
  • I'm not interested in the alignment of the questions. I'm just trying to add the same amount of \vspace after every question so I don't have empty space at the end. To illustrate, lets say if I didn't have any space after the questions, I was left with 20cm of space after question 20. Therefore I want to put 1cm of space after every question so that Question 20 only has the 1 cm of space after it. Of course this has to be done automatically because the lengths of the questions aren't known beforehand.
    – aligen
    Jun 15, 2021 at 12:27

2 Answers 2

1

This uses the same trick as multicols only over two pages instead of one. That is, it divides the text into 4 roughly equal columns BEFORE expanding \vfill. The problem is the columns are not precisely equal, nor are the number of \vfills per column equal.

\documentclass[12pt]{exam}
\usepackage{enumitem, multicol}
\usepackage{showframe}

\newsavebox{\tempbox}

\begin{document}
\large
\begin{multicols*}{2}
\global\setbox\tempbox=\vbox{\begin{questions}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing.
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\question This text means nothing. 
\begin{oneparchoices}
\choice 1 \choice 2 \choice 3 \choice 4
\end{oneparchoices}
\vspace{\fill}
\end{questions}}% end of \vbox
\setbox0=\vsplit\tempbox to 0.25\ht\tempbox
\setbox1=\vsplit\tempbox to 0.333\ht\tempbox
\setbox2=\vsplit\tempbox to 0.5\ht\tempbox
\unvbox0\columnbreak
\unvbox1\columnbreak
\unvbox2\columnbreak
\unvbox\tempbox
\end{multicols*}
\end{document}
2
  • Thanks for the reply! Can you explain what's going on in your code? Especially after the end of \vbox.
    – aligen
    Jun 15, 2021 at 12:17
  • \vsplit splits off part of a \vbox into another \vbox with a given height (not counting glue). Each time the original \vbox gets smaller. (This is how TeX splits paragraphs at the end of pages.) Jun 15, 2021 at 14:27
1

(1) To avoid having an empty last column of the second page use \begin {multicols}{2} instead of \begin {multicols*}{2}. There will be two balanced columns instead of a single column.

(2) To avoid having to insert the \vspace{...} after each question, the oneparchoices environment was modified to automatically include it at the end.

(3) Instead of using \vspace {\fill}, which distributes the space evenly within a page, but can vary from page to page, it's best to use a fixed length but with some glue added, to help LaTeX's page breaking mechanism to avoid, when possible, breaks between the question and the answers.

a

b

\documentclass[12pt]{exam}
\usepackage{enumitem, multicol}

%% ************************  added <<<
\AtEndEnvironment{oneparchoices}{%
%\vspace{0ex plus 0.5ex minus 0.5ex} % 16 questions en the first page   
%\vspace{0.8ex plus 0.5ex minus 0.5ex}% 15 questions but ..
\vspace{2ex plus 0.5ex minus 0.5ex} % 14 questions
%\vspace{3ex plus 0.5ex minus 0.5ex}  %13 questions
}
%% *************************

\begin{document}
    
\large
    \begin{multicols}{2}
        \begin{questions}

            \question This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question  This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question  This text means nothing. This text means nothing. This text means nothing.
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question  This text means nothing. This text means nothing. This text means nothing. This text means nothing. 
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    
            \question  This text means nothing. % last question
            \begin{oneparchoices}
                \choice 1 \choice 2 \choice 3 \choice 4
            \end{oneparchoices}
    %   \vspace*{\fill}  %<<<< uncomment for two columns, but not exactly balanced
        \end{questions} 

    \end{multicols}
\end{document}

If you do not like the spacing in last page, put \vspace*{\fill} before \end{questions} for two slightly unbalanced columns.

c

2
  • Thanks for the in-depth reply, the comments are really useful for someone like me! I've edited my document to use the \AtEndEnvironment command, (I had to import etoolbox). Spacing-wise, my main goal is to add \vspace{X} after everyone question so that there is little to no space left after Question 20's space. Since I don't know how long the questions are beforehand, I need X to be defined (and constant throughout the document) automatically. That's why I was using multicols*.
    – aligen
    Jun 15, 2021 at 12:23
  • Of course you can use \multicols* instead. Modifying the environment adds always same space, without the need to write \vspace every time. And is much easier if you want to modify the space between questions. Jun 15, 2021 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .