I'm using the package mcexam to build tests with randomised multiple choice questions and randomised answers.

The package usage is as follows:

\usepackage[output=exam, numberofversions=58, version=26, randomizequestions=true,randomizeanswers=true]{mcexam}

where with the option numberofversions I set the number of randomised tests, and with the option version I print the 26th version as a pdf output.

I would ask if it is possible to print more versions in the same output pdf (fo example from 1 to 25), without changing the version number every time to create the different output. Thank you


This is easy to achieve with \foreach. But care must be taken, to ensure that you don't end up with duplicate tests.

A randomization table is generated by the mcquestions environment, i.e. it will be different for each loop. So the tests will look randomized, but you may end up with duplicates.

To prevent this, seed must be set to constant value before the mcquestions environment and the version must be incremented in each loop.

The incementation is done by \foreach and version and seed are set with \setkeys.

Here is the code:

\usepackage[output=exam, numberofversions=58, randomizequestions=true,randomizeanswers=true]{mcexam}
\foreach \i in {1,...,25}{
    \question How much is $2+2$?
      \answer two
      \answer[correct] four
      \answer five
    \question How much is $5-3$?
      \answer 1
      \answer[correct] 2
      \answer 3
    \question How much is $0 \times 2$?
      \answer 1
      \answer 2
      \answer[correct] none of the above

Oh, and next time, please provide a minimal working example (MWE).

| improve this answer | |
  • I am trying to compile your answer, but I get this error <Incomplete \ifx; all text was ignored after line 30>. – Y_gr Jan 26 at 12:49

Your Answer

