A typical LaTeX file consists of a header part, which specifies auxiliary libraries and document parameters, and the actual content part. Instead of copying the standard header over and over, it’s better to save it in a separate file and include this file in each project with a single line. The proposed template for typesetting tests follows a similar ideology: standard commands are moved to a separate file, into which the specific file describing test variants is included.

It won’t take more than 15 minutes to understand the test template. Download the test archive (or see the contents at the bottom of this page). It contains three files:

These tex files are saved in UTF-8 encoding.

In the _gentest.tex file, you only need to pay attention to the line \newcommand{\numberOfVariants}{40}. The number 40 indicates the number of test variants that need to be generated. In the resulting PDF file, each variant will get its own number, although some variant texts may be identical.

In the variant.tex file, note the line \pagebreakafter{4} — it specifies how many variants fit on one page, this parameter needs to be set manually. Most importantly, the commands \p and \c are designed to set different variants of the same task. Consider this example: \begin{task} Compare the numbers \p2\c{25 and 46}\c{32 and 54}. \end{task}

The command \pNUMBER or \p{NUMBER} means that immediately after it will follow the corresponding number of different text modifications to be printed. The text itself goes in \c{...} commands. What’s written in the first/second/third/… such command will be included in the first/second/third/… test variant, cyclically. In the example above, in variants 1,3,5,7,…, the task will appear as “Compare the numbers 25 and 46”, and in even-numbered variants it will be “Compare the numbers 32 and 54”.

Everything becomes clear when comparing the variant.tex file and the result _gentest.pdf from the attached archive.

Compilation requires the LaTeX packages ifthen and calc. It’s also desirable to install the packages nopageno and indentfirst if they’re not present.

Template Source Code

Below is a GitHub Gist of the same code as in gentest.zip