Typesetting Multiple-Choice Questions in LaTeX

A tutorial on how to write a multiple-choice exam in LaTeX using the exam document class. Easily typeset your prepared questions with beautiful formatting.

In this tutorial, we will learn how to write a multiple-choice exam in LaTeX with the help of the exam document class. This will provide us with multiple tools to easily typeset questions and prepare exams — even by a LATEX novice — and customize them to however we want our exam to look.

The exam package provides us with four (4) environments for listing the possible answers to our exam — two of them put a label on the choices and the other two print checkboxes in front of the exam choices — for the students.

Finally, we will also learn how to prepare solutions for the exam, including fill-in-the-blank questions.

1. The choices environments

The choices environment (within the exam package) uses upper case letters (i.e., “A”, “B”, “C”, … ) to label the choices of the test questions. The choices environment creates a list environment with the choices as the items in the list. Here is a simple example.

\documentclass{exam}
\begin{document}

\begin{questions}

\question Here is a multiple-choice question using choices environment.
    \begin{choices}
       \choice The first choice.
       \choice The second choice.
       \choice The third choice.
       \choice The fourth choice.
    \end{choices}

\end{questions}
\end{document}
Multiple-choice using choices environment.

Looking at the example above, it should be noted that we can leave blank lines between the /choice command and the text of the choice, or between the various choices, and those blank lines will be ignored.

2. The oneparchoices environment

The oneparchoices environment on the other hand lists all of the choices in a single paragraph. This is a continuation of the paragraph preceding the environment unless you leave a blank line before beginning the environment.

If you use oneparchoices environment in the example above, then you’ll get:

\question Here is a multiple-choice question using oneparchoices environment.

    \begin{oneparchoices}
       \choice The first choice.
       \choice The second choice.
       \choice The third choice.
       \choice The fourth choice.
    \end{oneparchoices}
Multiple-choice questions using oneparchoices environment.

The blank line before the \begin{oneparchoices} is important because it is the one that causes the choices to be on the next line.

3. The checkboxes environment

The checkboxes environment belongs to the secondary category where it prints checkboxes in front of the choices for the students to use to place checks next to the chosen answers.

Just like the choices environment, the checkboxes environment creates a list environment with the choices as the items in the list. Using the same example above, then we’ll get:

\question Here is your multiple-choice question with a checkbox in front of the choices.
    \begin{checkboxes}
       \choice The first choice.
       \choice The second choice.
       \choice The third choice.
       \choice The fourth choice.
    \end{checkboxes}
Multiple-choice using checkboxes environment.

4. The oneparcheckboxes environment

The oneparcheckboxes environment lists all of the choices in a single paragraph which is a continuation of the paragraph (just like the oneparchoices environment).

\question Here is your multiple-choice question with a checkbox in front of the choices.
    
    \begin{oneparcheckboxes}
       \choice The first choice.
       \choice The second choice.
       \choice The third choice.
       \choice The fourth choice.
    \end{oneparcheckboxes}
Multiple choice questions using oneparcheckboxes environment.

Again, the blank line before the \begin{oneparcheckboxes} is deliberate in order for us to get the desired result.

Solutions to multiple-choice questions

The exam document class defines several environments for solutions. Of course, the answers will be printed only if you use the document class option answers (as in \documentclass[answers]{exam}).

The command \CorrectChoice is the LaTeX command to use to designate the correct answer(s). We can put one or more correct answers and will be emphasized when printed.

\question Which one doesn't belong to the group?
    \begin{choices}
       \choice Mercury
       \choice Venus
       \choice Jupiter
       \CorrectChoice LaTeX
    \end{choices}