First of all, the MCQ has to be described as a LaTeX file using the automultiplechoice package. This chapter describes the relevant LaTeX commands. You can check the LaTeX file you are designing at any moment by compiling it with the latex command, then visualizing the resulting dvi file.
We start with a few examples giving quick illustrations of how to build LaTeX files for MCQs; the corresponding tex file are available as templates, so that one can create a new MCQ project starting with one of these templates.
\documentclass[a4paper]{article} \usepackage[utf8x]{inputenc}\usepackage[T1]{fontenc} \usepackage[box,completemulti]{automultiplechoice}
\begin{document} \onecopy{10}{
%%% beginning of the test sheet header:
\noindent{\bf QCM \hfill TEST} \vspace*{.5cm} \begin{minipage}{.4\linewidth} \centering\large\bf Test\\ Examination on Jan., 1st, 2008\end{minipage} \namefield{\fbox{
\begin{minipage}{.5\linewidth} Firstname and lastname: \vspace*{.5cm}\dotfill \vspace*{1mm} \end{minipage} }} \begin{center}\em Duration : 10 minutes. No documents allowed. The use of electronic calculators is forbidden. Questions using the sign \multiSymbole{} may have zero, one or several correct answers. Other questions have a single correct answer. Negative points may be attributed to \emph{very bad} answers. \end{center} \vspace{1ex} %%% end of the header \begin{question}{prez}
Among the following persons, which one has ever been a President of the French Republic? \begin{choices} \correctchoice{René Coty} \wrongchoice{Alain Prost} \wrongchoice{Marcel Proust} \wrongchoice{Claude Monet} \end{choices} \end{question} \begin{questionmult}{pref}
Among the following cities, which ones are french prefectures? \begin{choices} \correctchoice{Poitiers} \wrongchoice{Sainte-Menehould} \correctchoice{Avignon} \end{choices} \end{questionmult} \clearpage
}
\end{document}
A few extra details on this example:
The packages inputenc and fontenc allow one to use the ISO-8859-1 (latin1) encoding. You can of course modify them depending on the encoding you want to use. | |
The options used here for the automultiplechoice
LaTeX package prevent questions from being split between
two pages ( | |
The onecopy command produces as many (distinct) realizations of the MCQ test as desired (here 10). See the section called “Description of a copy” for an alternative syntax using an environment. | |
Lines that start here describe the header of the test-sheet. | |
The namefield command specifies where students write their name. | |
The environments question and choices allow one to build a multiple choice question for which there is a single correct answer. A unique identifier for the question has to be specified (here: prez). | |
The environments questionmult and
choices allow one to build a multiple choice
question that may have zero, one or several correct answers.
Student are asked to check all the boxes corresponding to an
answer that she/he thinks is correct, or the last box (added
automatically thanks to the | |
The clearpage is used to start the next realization of the MCQ test on a new double page. | |
This marks the end of the onecopy command (started at line 9). |
In this example, we want the order in which questions appear in the MCQ test to be different from one realization of the test to the other, but still keeping together questions dealing with the same subject. To this end, we create two groups of questions, within which questions are shuffled at random.
\documentclass[a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc} \usepackage[box,completemulti]{automultiplechoice} \begin{document} %%% preparation of the groups \element{geographie}{ \begin{question}{Paris} In which continent is Paris? \begin{choices} \correctchoice{Europe} \wrongchoice{Africa} \wrongchoice{Asia} \wrongchoice{planet Mars} \end{choices} \end{question} } \element{geographie}{ \begin{question}{Cameroon} Which is the capital city of Cameroon? \begin{choices} \correctchoice{Yaoundé} \wrongchoice{Douala} \wrongchoice{Abou-Dabi} \end{choices} \end{question} } \element{histoire}{ \begin{question}{Marignan} In which year did the battle of Marignan take place? \begin{choiceshoriz} \correctchoice{1515} \wrongchoice{1915} \wrongchoice{1519} \end{choiceshoriz} \end{question} } \element{histoire}{ \begin{questionmult}{Nantes} What can be said about the \emph{Édit de Nantes}? \begin{choices} \correctchoice{It was signed in 1598} \correctchoice{Il has been revoked by Louis XIV} \wrongchoice{It was signed by Henri II} \end{choices} \end{questionmult} } %%% copies \onecopy{10}{ %%% beginning of the test sheet header: \noindent{\bf QCM \hfill TEST} \vspace*{.5cm} \begin{minipage}{.4\linewidth} \centering\large\bf History and geography\\ Examination on Jan. 1st, 2008 \end{minipage} \namefield{\fbox{\begin{minipage}{.5\linewidth} Firstname and lastname: \vspace*{.5cm}\dotfill \vspace*{1mm} \end{minipage}}} %%% end of the header \begin{center} \hrule\vspace{2mm} \bf\Large Geography \vspace{1mm}\hrule \end{center} \shufflegroup{geographie} \insertgroup{geographie} \begin{center} \hrule\vspace{2mm} \bf\Large History \vspace{2mm}\hrule \end{center} \shufflegroup{histoire} \insertgroup{histoire} \clearpage } \end{document}
In this example, one wants the check-boxes to be put together in a separate sheet. This makes cheating more difficult, and, more importantly, it is enough to scan a single sheet per student, which makes things easier if one has to do a manual scan. In this example, the number of questions is limited: they fit into a single page, so that such a layout would not be really useful in this particular case. It is up to you to modify this example in order to use this layout with a large number of questions!
\documentclass[a4paper]{article} \usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc} \usepackage[box,completemulti,separateanswersheet]{automultiplechoice}\begin{document} \AMCrandomseed{1237893} \def\AMCformQuestion#1{\vspace{\AMCformVSpace}\par {\sc Question #1:} }
\element{general}{ \begin{question}{prez} Among the following persons, which one has ever been a President of the French Republic? \begin{choices} \correctchoice{René Coty} \wrongchoice{Alain Prost} \wrongchoice{Marcel Proust} \wrongchoice{Claude Monet} \end{choices} \end{question} } \element{general}{ \begin{questionmult}{pref} Among the following cities, which ones are french prefectures? \begin{choices} \correctchoice{Poitiers} \wrongchoice{Sainte-Menehould} \correctchoice{Avignon} \end{choices} \end{questionmult} } \element{general}{ \begin{question}{nb-ue} How many different states were members of the European Union in Jan. 2009? \begin{choiceshoriz}[o] \wrongchoice{15} \wrongchoice{21} \wrongchoice{25} \correctchoice{27} \wrongchoice{31} \end{choiceshoriz} \end{question} } \onecopy{5}{ %%% beginning of the test sheet header: \noindent{\bf QCM \hfill TEST} \vspace*{.5cm} \begin{minipage}{.4\linewidth} \centering\large\bf Test\\ Examination on Jan. 1st, 2008 \end{minipage} \begin{center}\em Durée : 10 minutes. No documents allowed. The use of electronic calculators is forbidden. Questions using the sign \multiSymbole{} may have zero, one or several correct answers. Other questions have a single correct answer. Negative points may be attributed to \emph{very bad} answers. \end{center} \vspace{1ex} %%% end of the header \shufflegroup{general} \insertgroup{general} \AMCcleardoublepage
\AMCformBegin
%%% beginning of the answer sheet header {\large\bf Answer sheet:} \hfill \namefield{\fbox{
\begin{minipage}{.5\linewidth} Firstname and lastname: \vspace*{.5cm}\dotfill \vspace*{1mm} \end{minipage} }} \begin{center} \bf\em Answers must be given exclusively on this sheet: answers given on the other sheets will be ignored. \end{center} %%% end of the answer sheet header \AMCform
\clearpage } \end{document}
The following remarks should make the above example clearer :
The | |
One can re-define in this manner the way the questions are identified on the answer sheet (this line is optional). | |
This page break is put before the special page where the check-boxes are put together. If one does recto-verso printing, it is preferable to use \AMCcleardoublepage so that this page is printed apart from the others. In the case of recto printing, one can simply use \clearpage. | |
This command marks the beginning of the answer sheet part. Its use is necessary for the appropriate treatment of the questions which appear only in that part, e.g. those generated by AMCcode. | |
Students should normally write their name on the answer sheet! | |
The LaTeX command AMCform writes all the check-boxes. |
![]() | Warning |
---|---|
When one uses a separate answer sheet, letters (or digits, if
one uses the option |
To use the automultiplechoice package, one uses the line
\usepackage[...]{automultiplechoice}
where the dots are replaced by a list of options separated by commas. Here are the available options:
lang=
: sets
the subject language to XX
XX
. At present,
only FR (french) and ES (spain) are available. Several strings
added by automultiplechoice will be translated,
such as "None of these answers are correct", see option
completemulti
.
box
: puts every question in a block, so
that it cannot be split by a page break.
completemulti
: automatically adds a "None
of these answers are correct" choice at the end of each multiple
question. Thus, for these questions, a distinction can be made
between no answer and the answer consisting in treating none of
the listed answers as correct.
noshuffle
: stops the automatic shuffling of
the answers for every question
answers
: produces the corrected version of
the MCQ test, not the test sheet itself.
separateanswersheet
: requires that all
check-boxes be put together at the end of the test sheet (usually,
this option is used when one wants to have only one sheet to scan
per student - see the example in section the section called “An example with a separate answer sheet”).
digits
: if one uses the
separateanswersheet
option, the
digits
option requires the question to be
identified with digits rather than with letters (which corresponds
to the default setting). With this option, one has to take care
that the number of answers does not exceed 9.
outsidebox
: when using
separateanswersheet
, this option asks to print
letters (or digits) outside the boxes on the answer sheet.
insidebox
: when not using
separateanswersheet
, this options asks to print
letters (or digits) inside the boxes to be filled by the
students.
catalog
: use this option to make a catalog
of your questions to be used to compose future exams. No need to
use \onecopy with this layout.
postcorrect
: use this option if you want to
give the correct answers after scans analysis, from a teacher
completed answer sheet - see for details.
The LaTeX source code describing the content of the test sheet has to be included in a call to the command \onecopy, the first argument being the number of distinct realizations to be produced, and the second argument being the code used to generate a realization.
\onecopy{50}{ ... }
If you have downloaded the LaTeX package environ before automultiplechoice, an alternative syntax is available, using the examcopy environment, where the number of realizations is an option (default is 5).
\begin{examcopy}[50] ... \end{examcopy}
![]() | Note |
---|---|
The environ package is not available in the TeX Live 2007 distribution, which is still used in Ubuntu distributions up to version 9.10 (Karmic Koala). |
For simple questions (a single correct answer), one uses the following model:
\begin{question}{identifiant} Here is the question... \begin{choices} \correctchoice{The correct answer} \wrongchoice{A wrong answer} \wrongchoice{Another wrong answer} \end{choices} \end{question}
![]() | Important |
---|---|
One must use a different identifier for every question. An identifier can be made of digits, letters, and simple characters (but do not use e.g. braces or brackets). Don't end your question identifier with a dot followed by digits, as this syntax is reserved to codes input. |
![]() | Note |
---|---|
The maximum number of answers for a given question is limited to 199. |
To keep the original order of the answers and prevent shuffling
for this specific question, one can use the o
option
of the choices
environment, replacing line 3 by the
following:
\begin{choices}[o]
To put the answers on two columns, one can use the multicol package by putting in the preamble (just after the reference to the package automultiplechoice for instance) the following
\usepackage{multicol}
and by including the choices environment inside a multicols environment in the following manner:
\begin{multicols}{2} \begin{choices} \correctchoice{The correct answer} \wrongchoice{A wrong answer} \wrongchoice{Another wrong answer} \end{choices} \end{multicols}
For even shorter answers, one can require questions to be
printed following one another, using the
choiceshoriz
environment instead of choices
.
Multiple questions (those for which no, one, or several answers
can be correct) use the questionmult
environment
instead of question
.
When the answer to the question is not supposed to be taken into
account in the grading, one uses the \QuestionIndicative
command, as in the following example:
\begin{question}{difficulty}\QuestionIndicative \scoring{auto=0,v=-1,e=-2} Did you find this class easy or difficult? Please answer on a scale from 0 (very difficult) to 5 (very easy). \begin{choiceshoriz}[o] \correctchoice{0} \correctchoice{1} \correctchoice{2} \correctchoice{3} \correctchoice{4} \correctchoice{5} \end{choiceshoriz} \end{question}
To put answers on several columns (and thus save space), one can
embed the choices
environment in a
multicols
environment, using the LaTeX package
multicol.
If, moreover, the answers do not fit into a single line, an answer might be split over several columns, which might be a little puzzling for the reader. The \AMCBoxedAnswers command was defined in order to prevent this phenomenon, by embedding each answer into a box. Here is an example of use:
\begin{question}{two columns} What is a bird ? \begin{multicols}{2}\AMCBoxedAnswers \begin{choices} \correctchoice{It is an animal with wings, laying eggs. There are birds with all sorts of colors.} \wrongchoice{It is a large piece of furniture, made of wood, and used most of the time to store household linen} \wrongchoice{It is a steam machine devised to seal cans at high speed.} \end{choices} \end{multicols} \end{question}
Let us note that it is also possible to parametrize the vertical
space between two answer blocks, thanks to the dimension
AMCinterBrep
:
\AMCinterBrep=.5ex
Putting questions into groups allows one to shuffle questions inside these groups, in a different way for each realization of the test. Every group of questions must have a name formed solely with plain letters.
One can put questions in a group one by one, as in the following example.
\element{mygroup}{ \begin{question}{easy} So, how much is one plus one? \begin{choiceshoriz} \correctchoice{two} \wrongchoice{zero} \wrongchoice{three} \end{choiceshoriz} \end{question} }
![]() | Important |
---|---|
The formation of the group, using the element commands, must be made only once: thus, these commands have to be used before the onecopy command, which repeats some actions for every realization. |
Once a group is formed, it is possible to shuffle questions inside this group using the shufflegroup command. For instance
\shufflegroup{mygroup}
Finally, the group content can be output to the test sheet using command insertgroup, as in
\insertgroup{mygroup}
![]() | Note |
---|---|
These last two commands (shufflegroup and insertgroup) are to be used inside the argument of the command onecopy, so that shuffling is performed before each realization. |
Groups of questions can be manipulated more precisely thanks to the following commands:
\insertgroup[n]{mygroup}
(using optional
parameterl n
) only inserts the
n
first elements from the group.
\cleargroup{mygroup}
clears all group
content.
\copygroup{groupA}{groupB}
copies all the
elements from group groupA
to the end
of group groupB
. With an optional
argument n
, only the n first elements
will be copied: \copygroup[n]{groupA}{groupB}
.
With these commands, you can for exemple make a exam taking 4 questions from group GA at random, 5 questions from group GB at random, and all the questions from group GO, shuffling all these questions, with the following code (to be used inside the argument of the command onecopy):
\cleargroup{all} \shufflegroup{GA}\copygroup[4]{GA}{all} \shufflegroup{GB}\copygroup[5]{GB}{all} \copygroup{GO}{all} \shufflegroupe{all} \insertgroup{all}
The \AMCboxDimensions command allows one to modify one or several dimensions of the check-boxes.
size
is the size of the box;
rule
is the thickness of the boundary of
the box;
down
controls by how much boxes are pushed
down.
To obtain smaller boxes, one can e.g. use the command
\AMCboxDimensions{size=1.7ex,down=.2ex}
When using separateanswersheet
package option,
you can also customize the boxes labelling. The default behaviour is
to use uppercase alphabetical labelling, or arabic numbering if the
digits
package option is used. To use your own
labelling, one has to redefine the \AMCchoiceLabel
command which takes as argument the name of the counter used to number
the choices. For example, the following code will ask for lowercase
letters to label the boxes:
\def\AMCchoiceLabel#1{\alph{#1}}
As an other example, when using arabxetex package, the following code may be useful:
\def\AMCchoiceLabel#1{\textLR{\Alph{#1}}}
The way each question is presented can be modified by redefining the LaTeX command AMCbeginQuestion, whose default definition is the following:
\def\AMCbeginQuestion#1#2{\par\noindent{\bf Question #1} #2\hspace*{1em}}
The first parameter transmitted to this command is the number of
the question to be displayed. The second parameter contains
\multiSymbole
in the case of a multiple question, and is
void in all other cases. The \multiSymbole
command too
can be modified: its goal is to distinguish multiple questions from
the others. By default, it displays a club.
\def\multiSymbole{$\clubsuit$}
Finally, one can modify the number of the next question with the
\AMCnumero command
. At the beginning of each realization
of the test, a call to
\AMCnumero{1}
is performed, but this command can be used at any place.
The display of answers can be modified in the same fashion, if
one uses the choicescustom
environment instead of
choices
or choiceshoriz
, redefining
the three following LaTeX macros:
\def\AMCbeginAnswer{} \def\AMCendAnswer{} \def\AMCanswer#1#2{#1 #2}
It is also possible to modify the layout of the separate answer
sheet produced with the separateanswersheet
option
(see section the section called “An example with a separate answer sheet”).
If one only wants to modify the horizontal spacing between two check-boxes or the vertical spacing between two questions, one just has to redefine the following dimensions:
\AMCformHSpace=.3em \AMCformVSpace=1.2ex
For a deeper modification of the display settings, one can also redefine the commands that are used at the beginning of each question and for each answer (here follows the default definitions):
\def\AMCformQuestion#1{\vspace{\AMCformVSpace}\par{\bf Question #1:}} \def\AMCformAnswer#1{\hspace{\AMCformHSpace} #1}
These definitions have to be inserted just after
\begin{document}
in the LaTeX file.
Code acquisition can be easily performed thanks to the LaTeX command AMCcode, for instance to allow each student to enter her/his student number by herself/himself on the answer sheet. The two arguments of this command are a code/question identifier, and the number of digits to be used by the code. One can e.g. use the following header
{\setlength{\parindent}{0pt}\hspace*{\fill}\AMCcode{etu}{8}\hspace*{\fill} \begin{minipage}[b]{6.5cm} $\longleftarrow{}$\hspace{0pt plus 1cm} please encode your student number below, and write your first and last names below. \vspace{3ex} \hfill\champnom{\fbox{ \begin{minipage}{.9\linewidth} Firstname and lastname: \vspace*{.5cm}\dotfill \vspace*{.5cm}\dotfill \vspace*{1mm} \end{minipage} }}\hfill\vspace{5ex}\end{minipage}\hspace*{\fill} }
If the separateanswersheet
option is used, the
AMCcode command has to be placed after the
AMCdebutFormulaire command.
Note that the codes rendering from \AMCcode can be adapted modifying the lenghts \AMCcodeHspace, \AMCcodeVspace and \AMCcodeBoxSep, representing the horizontal and vertical amount of space between boxes, and the amount of space between boxes and labels (when the labels are written outside the boxes). Defaut values are set with the following commands:
\AMCcodeHspace=.5em \AMCcodeVspace=.5em \AMCcodeBoxSep=.1em
Note that an horizontal version AMCcodeH is also available, specially for the case of small number of digits.
One can modify the seed of the random number generator used to produce the shuffle, thanks to the following command (to be used just at the beginning of the document, and in any case outside the onecopy command):
\AMCrandomseed{1527384}
If the value that is assigned (to be chosen between 1 and 4194303) is modified, then the shuffling will differ. Of course, one must not modify this value after the test sheets have been printed.
Using LaTeX commands \label and \ref within questions or answers is problematic since they will be called with the same arguments for every realization of the test, which will alter the numbering of references. To solve this problem, one should use instead the commands\AMClabel and \AMCref: they add the realization number to their argument before transmitting it to \label et \ref.
One also has to reset counters to zero at the beginning of each realization. For instance, if one wants to include references to pictures that are put together in a separate page, one might write something like
\element{animals}{ \begin{figure}[p] \centering \includegraphics[width=.6\linewidth]{tiger} \caption{An animal} \AMClabel{tiger} \end{figure} \begin{question}{tiger} Which is the animal on figure~\AMCref{tiger}? \begin{choices} \correctchoice{A tiger} \wrongchoice{A giraffe} \wrongchoice{An elephant} \wrongchoice{A cat} \end{choices} \end{question} }
and it is then important to add, just after the command \onecopy the line
\setcounter{figure}{0}
so that the numbering of figures starts at 1 for every realization. Without that last command, the numbering of figures would go on from one realization to the next one, which is clearly not desirable.
Use \AMCtext for the following customizations:
\AMCtext{none}{
replaces « None of these answers are correct. » (the English
default text) with the given sentence
}sentence
when using option completemulti
.
\AMCtext{corrected}{
replaces « Corrected » (the English default text) with the given
title
}title
on the corrected answer
sheet.
\AMCtext{catalog}{
replaces « Catalog » (the English default text) with the given
title
}title
on the questions catalog produced
thanks to option catalog
.
You can also consider using commands like the following ones (here the second argument is set to the default English value):
\AMCtext{draft}{DRAFT} \AMCtext{message}{For your examination, preferably print documents compiled from auto-multiple-choice.}
Thanks to the LaTeX package fp, whose documentation is available at http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=fp, and which can be downloaded with the command
\usepackage{fp}
added before that corresponding to automultiplechoice, one can create exercises with randomized numerical data. Let us start with a simple example.
\begin{question}{addition} \FPeval\VQa{trunc(1+random*8,0)}\FPeval\VQb{trunc(4+random*5,0)} \FPeval\VQsomme{clip(VQa+VQb)}
\FPeval\VQnonA{clip(VQa+VQb-1)}
\FPeval\VQnonB{clip(VQa*VQb)} \FPeval\VQnonC{clip(VQa-VQb)} What is the sum of \VQa{} et \VQb{} ? \begin{choiceshoriz} \correctchoice{\VQsomme} \wrongchoice{\VQnonA} \wrongchoice{\VQnonB} \wrongchoice{\VQnonC} \end{choiceshoriz} \end{question}
The \FPeval command is used to perform computations:
Since random returns a real number in the interval [0,1], this command sets VQa to a random integer value between 1 et 8. The next line sets VQb to a random integer value between 4 et 8. | |
Putting the correct answer in the variable VQsomme. | |
Putting wrong answers in variables VQnonA, VQnonB et VQnonC... |
Variable names beginning with VQ have been chosen so as to avoid interference with other LaTeX commands.
The automultiplechoice package moreover defines a \choixIntervalle command which makes this kind of construction simpler, as illustrated in the next example:
\begin{question}{inf-expo-indep} \FPeval\VQa{trunc(2 + random * 4,0)} \FPeval\VQb{trunc(6 + random * 5,0)} \FPeval\VQr{VQa/(VQa+VQb)} Let $X$ and $Y$ be two independent random variables, following the exponential distribution with respective parameters \VQa{} et \VQb{}. To which interval does the probability $\mathbb{P}[X<Y]$ belong ? \begin{multicols}{5} \begin{choices}[o] \choixIntervalles{\VQr}{0}{1}{0.1}\end{choices} \end{multicols} \end{question}
This lines inserts ten answers corresponding to the intervals [0,0.1[ [0.1,0.2[ ... [0.9,1[, while indicating that the correct interval is the one containing VQr. The arguments of the \choixIntervalle command are the following:
|