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!

//

I teach tutorials in Economics 101. Yesterday an international student asked me to explain why “one of the American political parties” thinks cutting tax rates will increase fiscal revenues. I explained that their theory is that lowering taxes will encourage people to work, spend, and invest more; that this would spur economic growth; and that even a lower tax rate on this higher GDP could actually generate higher revenues.

“Oh, that’s interesting. Is it true?” was his reply.

I thought about it for a second. I briefly considered the implications of answering a politically-charged question. I worried a little that this was a student whose interest in economics was piqued, and that I ran the risk of blunting that interest. After contemplating whether I should answer whether it was theoretically possible or empirically verifiable, I gave him the most honest answer I could: “No.”

The consensus among economists is that although this “bigger cake” idea has some truth to it, lowering taxes does not increase the cake anywhere near enough to make a significant difference. Harald Uhlig thinks higher tax rates could increase American income tax revenue by 30%; the Congressional Budget Office thinks that although lowering tax rates would lead to more economic activity, the revenue generated by these new activities would only be a quarter of the revenue lost in the initial tax cut; and even Greg Mankiw, chairman of the Council of Economic Advisers to President Bush (the second), thinks this thesis is a bit silly.

//

Students should feel free to email me with any complaints or queries. Nonetheless, I understand if there are some issues that they would rather raise anonymously. To that end, I have written a small PHP script that will allow them to email me without providing any personal details. To prevent spam I don’t want to link to it directly but if x=hargaden, then it’s available at x.com/enda/feedback

I’m not that familiar with PHP and was surprised to find that sending an email can be done by calling a single function with three arguments, i.e. only one line of code. For an example, see here.

//
Scroll to Top