I would like to set up an environment for multiple choice questions, such that the list of the correct answers, and some lines of comments, will be typeset at the end of the chapter.
Something like this:
\question
This is the question
\choice First guess
\truechoice Second guess {This is a comment that goes at the end of the chapter}
\choice Third guess
At the end of the chapter, I would like to have a list of question numbers (automatically written), the correct answer (correctly numbered), and the comment.
How could i do?
Best Answer
Here's a bit of a hack using the
endnotes
package. I tried to inline some comments.And here's the output:
Edit:
In response to zar's comment below, if we want the input syntax to be
instead of
one can change the definition to
But this way you have to put the choice text in braces, for example, you must write
Edit 2: S.G. and zar noticed some problems with my abuse of the
\edef
function. A more complicated, but functionally better hack is the following (I'm including the full file below for easy of copy-pasting)and this is what it outputs
which as one can see correctly handles the
\emph
command and math (both displayed and inline) environments.