I want to write a book which will consist of many multiple choice exam sheets. Putting the codes below into my preamble, I wrote the question like as
\begin{enumerate}
\item $2+2=?$
\choice $1$ \choice $2$ \choice $3$ \choice $4$ \choice $5$
\end{enumerate}
For each exam sheet, in the footer I want to create a table of correct answers. Is there any simple way to do this, or a LaTeX macro script to do this automatically by mentioning correct answer in its LaTeX codes? For example;
\choice 1 \choice 2 \choice 3 \correctchoice 4 \choice 5
In addition, since the choices are not side by side, I have lost many spaces. Is there any LaTeX codes to write choices more symmetrically and automatically in one or two row?
%%% Codes in preamble %%%
\newcounter{choice}
\renewcommand\thechoice{\Alph{choice}}
\newcommand\choicelabel{\thechoice)}
\newenvironment{choices}%
{\list{\choicelabel}% {\usecounter{choice}\def\makelabel##1{\hss\llap{##1}}% \settowidth{\leftmargin}{W.\hskip\labelsep\hskip 1.5em}% \def\choice{% \item } % choice \labelwidth\leftmargin\advance\labelwidth-\labelsep \topsep=0pt \partopsep=0pt }% }%
{\endlist}
\newenvironment{oneparchoices}%
{% \setcounter{choice}{0}% \def\choice{% \refstepcounter{choice}% \ifnum\value{choice}>1\relax \penalty -50\hskip 1em plus 1em\relax \fi \choicelabel \nobreak\enskip }% choice % If we're continuing the paragraph containing the question, %then leave a bit of space before the first choice:
\ifvmode\else\enskip\fi
\ignorespaces
}%
Best Answer
Here's a variation on my earlier answer. In this version, the choices aren't part of any environment; you just start listing
\choice
s and\correctchoice
s after the question.Here's a complete LaTeX file that illustrates it.