I was writing a series of practice multi-choice questions for the class I teach when I decided I wanted to write a LaTeX function to automate the formatting. I wanted to include the answer as an argument of that function (possibly with room for an explanation) but not to display the answer until the end of the document. (This is a reasonably simple process. For a more hardcore setup, see the eqexam package.)

I hacked away at the endnotes package until I got what I wanted. Editing packages is a pain though, so I summarized the changes into a Questions and Answers class: qanda.cls.

This does the dirty work in the background and defines two new commands: \q and \qtf. The former takes six arguments: the question, four multi-choice options, and the answer. The latter takes four arguments: the question, two multi-choice options (e.g. true and false, thus the tf in command name), and the answer.

This makes writing multi-choice questions very easy. Here is some sample code.
[sourcecode]
\documentclass{qanda}
\title{An Example of the qanda Class}
\author{Enda Hargaden}
\begin{document}
\maketitle
This document is an example of the output of the qanda (“q and a”) class.

\q{Who wrote \textit{Animal Farm}?}{Hargaden}{Orwell}{Marx}{Huxley}{Orwell}
\qtf{There are subtle historical parallels in \textit{Animal Farm}.}{True}{False}{True; it is an allegory for the unfortunate route Communism took.}
\q{Who wrote \textit{Capital}?}{Hargaden}{Orwell}{Marx}{Huxley}{Marx}

\newpage
\theendnotes

\end{document}
[/sourcecode]
This produces this nifty document.

To use the qanda class:

  1. Download qanda.cls
  2. Place it in the folder your .tex is in
  3. Start your document with \documentclass{qanda}

To produce the answers to your questions, simply include the \theendnotes command where you want them in your document. Preface this with \newpage if you want them on a new page.

Note that the qanda class is based on the scrartcl class, so you need that on your computer. You also will need to have installed the enumerate and setspace packages.

Enjoy!

//
Scroll to Top