Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
Short answer. To typeset multiple-choice questions in LaTeX, load the exam document class, put each question inside a questions environment, and list the options with \choice inside a choices, oneparchoices, checkboxes or oneparcheckboxes environment. Mark the right option with \CorrectChoice and the same source file produces both a student paper and an answer key.
This page is for researchers, instructors and analysts who already compile LaTeX documents and need to produce a quiz or exam from one source file. Everything below follows the exam class manual and its CTAN entry, read on 2026-11-08.
What it is used for in research
Researchers who teach, run training courses, or build knowledge checks often want printable multiple-choice items with a matching answer key. The exam class by Philip Hirschhorn keeps both versions in a single file, so the questions and the key cannot drift apart. Searches phrased as “multiple choice LaTeX” describe the same task: the question syntax is identical.
If you need general document structure first, see the structure of a LaTeX document.
How to install or access it
The class is distributed on CTAN at ctan.org/pkg/exam. The CTAN entry lists version 2.704 under the LaTeX Project Public License 1.3, with the last CTAN announcement dated 2023-07-11 (checked 2026-11-08). The manual is at mirrors.ctan.org/macros/latex/contrib/exam/examdoc.pdf.
Do not install the separate “exams” bundle alongside it. The CTAN page warns that the exams bundle ships its own, conflicting exam.cls. If you work in an online editor, see web-based LaTeX editors; Overleaf documents the same workflow in its Typesetting exams in LaTeX article.
Step-by-step: a multiple-choice question with an answer key
1. Write the question
Load the class, open the questions environment, and write each item with \question. This follows the example in section 5.5 of the manual, with the correct option marked:
\documentclass{exam}
\begin{document}
\begin{questions}
\question Which philosopher was the teacher of Plato?
\begin{oneparchoices}
\choice Aristotle
\CorrectChoice Socrates
\choice Epicurus
\choice Zeno
\end{oneparchoices}
\end{questions}
\end{document}
2. Choose a layout
The manual (section 5) defines four environments for the options:
| Environment | Layout | Marker before each option |
|---|---|---|
choices |
A list, one option per line | Upper-case letter and a period: A., B., C. |
oneparchoices |
All options in a single paragraph | Upper-case letter and a period |
checkboxes |
A list, one option per line | A checkbox |
oneparcheckboxes |
All options in a single paragraph | A checkbox |
For the one-paragraph variants, the options continue the preceding paragraph unless a blank line comes before \begin. Blank lines between \choice and its text are ignored.
3. Mark the correct option
Use \CorrectChoice in place of \choice for the right answer; \correctchoice is a synonym. When solutions are not printed, it behaves exactly like \choice, so the student version shows no difference.
4. Build the answer key
Solutions print only when you add the answers class option, or put \printanswers in the file (the two are equivalent):
\documentclass[answers]{exam}
Compile once without the option for the student paper and once with it for the key.
Output and how to read it
In the student build, every option looks the same. In the answer build, the correct option is set in bold by default (\CorrectChoiceEmphasis defaults to \bfseries). In checkboxes and oneparcheckboxes, the checkbox of the correct option is replaced by a check instead.
Changing the labels and the emphasis
The option label is controlled by \choicelabel, whose default is \thechoice. (manual section 4.9). The answer emphasis can be redefined as well:
\renewcommand{\choicelabel}{\thechoice)}
\renewcommand{\CorrectChoiceEmphasis}{\itshape}
Other answer aids
\answerline[answer] prints a line and shows the optional answer text when solutions are printed; \fillin[answer][length] does the same for fill-in-the-blank items.
Randomizing the order of choices
The exam-randomizechoices package (README on CTAN) adds environments that shuffle the options: randomizechoices, randomizeoneparchoices, randomizecheckboxes and randomizeoneparcheckboxes. It shuffles the options only, not the order of the questions.
\documentclass{exam}
\usepackage{exam-randomizechoices}
\begin{document}
\begin{questions}
\question Which philosopher was the teacher of Plato?
\begin{randomizechoices}
\choice Aristotle
\CorrectChoice Socrates
\choice Epicurus
\choice Zeno
\end{randomizechoices}
\end{questions}
\end{document}
| Package option | Effect |
|---|---|
randomize |
Shuffle the options (default) |
norandomize |
Keep the written order |
keeplast |
Keep the last option in place |
nokeeplast |
Allow the last option to move (default) |
overload |
Redefine the standard environments to randomize (off by default) |
nooverload |
Leave the standard environments alone (default) |
debug |
Debug mode |
Verbatim and listings content is not supported inside these environments.
Troubleshooting
- Odd errors after installing. You may have both
examand theexamsbundle; the bundle’sexam.clsconflicts with this class. Keep only one. - The correct answer is not marked. Solutions print only with
[answers]or\printanswers. Without them\CorrectChoiceacts like\choice. - The options run into the previous paragraph. In the one-paragraph environments, add a blank line before
\begin{oneparchoices}. - Code fails inside a randomized block. Verbatim and
listingsmaterial is not supported inside the randomizing environments; use the standard environments for those items.
Free alternatives
| Option | What it adds | Source |
|---|---|---|
exam class |
Questions, four option layouts, answer key from one source | CTAN, LPPL 1.3 |
exam-randomizechoices |
Shuffled options for use with exam |
CTAN README |
To wrap your own question layouts in macros, see newcommand in LaTeX; for tabular layouts around items see multirow in LaTeX.
FAQ
How do I make multiple choice questions in LaTeX?
Load \documentclass{exam}, wrap items in questions, start each with \question, and list options with \choice inside choices or oneparchoices.
Is “multiple choice LaTeX” a different task?
No. It is the same task phrased the other way round; the same exam class syntax applies.
How do I highlight the correct answer?
Use \CorrectChoice and compile with [answers] or \printanswers; the correct option is bold by default, or checked in the checkbox environments.
Can I use checkboxes instead of letters?
Yes: use checkboxes or oneparcheckboxes.
Can the options be shuffled?
Yes, with the exam-randomizechoices package; only the options are shuffled, not the questions.
Sources
- Hirschhorn, Using the exam document class, sections 3.2, 4.9, 5 and 5.5: examdoc.pdf
- CTAN, exam package page
- CTAN, exam-randomizechoices README
- Overleaf, Typesetting exams in LaTeX







