Preparation of blank tests is not a fun lesson. Not only do you need to make a list of questions and answer choices, you can also draw forms, and then create one sample form with the correct answer choices (to make it easier to check).
However, TeX is a very powerful system that can even solve cubic equations! Can she not cope with such a simple task? Cope, and how!
So, we will write the unpretentious style file allowing from the text
\documentclass[a4paper,14pt]{extarticle} \usepackage[koi8-r]{inputenc} % \usepackage[russian]{babel} % \usepackage{./TESTS} % \begin{document} \begin{enumerate} \begin{q}{ , ?} \item \good \item \end{q} \begin{q}{ ?} \item 3 \item 4 \item \item 2-4 \good \end{q} \begin{q}{ / ?} \item \item 4 (\verb'\q', \verb'\good', \verb'\showtbl' \verb'\trueans')\good \item 3 \end{q} \end{enumerate} \newpage \showtbl \newpage \trueans \end{document}
Get this test:

')
To him here is the form:

And such a standard:

For this we need a little. First, let's redefine the enumerate environment so that it looks the way we need it. In addition, this environment should depend on our own counter, which we can use to compare the numbers of answers and questions:
\newcounter{lst} \renewenvironment{enumerate}
With the first team, we added our own lst counter. Then we redefine the enumerate environment: it will use the lst counter, after the question number a dot will be put, we will not insert extra gaps (except for two millimeter meters, which divide questions between themselves).
Next, we define an environment q in which we will “wrap” answer options. This should be a numbered list, the numbering of which is given in Russian letters. For him, we will also set our own counter.
\newcounter{qwest} \def\theqwest{\arabic{qwest}} \newenvironment{q}[1]{\item #1 \begin{list}{\asbuk{qwest})}{\usecounter{qwest}}}{\end{list}\par}
The environment we ask with one mandatory parameter - the text of the question.
In order to mark the correct answer, you can use the standard Tekhovsky tool output to the file, but you can not fence the bicycle, and use the already ready interface - Latek marks. Since the label saves the value of the last modified counter, placing it after the text of the correct answer, we will automatically save the number of this answer. But the question number will have to be saved manually, we will place it in the text of the label with the prefix "q":
\newcount\total \total=0 \def\good{\label{q\arabic{lst}}\global\advance\total by1}
The total counter will contain the total number of questions. Note that if we use more than one good command in a question, we will get an error (the total counter will exceed the total number of questions, the error text will indicate an invalid 'q' link).
To build the blanks and the standard, we need additional counters:
\newcount\cone \newcount\ctwo \newcount\cthree
In addition, we define the auxiliary commands. In order to select from our link "q <question number>" the correct answer (and that it was the value of the counter), let's redefine the ref command:
\def\f@rst#1#2{#1} \def\ref#1{\expandafter\@setref\csname r@#1\endcsname\f@rst#1}
The blank and the standard of answers will be drawn in the form of a table with 10 questions per line, and since we will also need to fill in the correct answers (which we design in the form of columns); in this table, each cell corresponding to one question will be a nested table column. Non-existent questions (when the number of questions is not a multiple of ten) are replaced by the symbol
X.The blank of the blank is the same for both test and reference. Therefore, in both cases we use the same command to build this header:
\def\l@@n@{&} \def\l@n@{\ifnum\cone<\ctwo\gdef\c@ll{\number\cone}\else\gdef\c@ll{\bf X}\fi \global\advance\cone by1\global\advance\cthree by1 \l@@n@\hbox to 1cm{\hfil\c@ll\hfil} \ifnum\cthree<10\l@n@\fi}
The first definition had to be made, since otherwise in the second symbol & revealed.
The l @ n @ command checks if the number of the current question (cone) is less than the total number of questions (ctwo), if so, the question number is placed in the column heading, otherwise, the
X character. The number of the current question increases, as well as the count of the number of questions in the current line (cthree), if this counter is less than ten, the recursive call of the same command continues.
The contents of the blank table are simple (empty table), so it is logical to draw it “in one sitting”:
\def\bl@nk{\hbox to 2.5cm{\hfil )\hfil}&&&&&&&&&&\\\hline \hbox to 2.5cm{\hfil )\hfil}&&&&&&&&&&\\\hline \hbox to 2.5cm{\hfil )\hfil}&&&&&&&&&&\\\hline \hbox to 2.5cm{\hfil )\hfil}&&&&&&&&&&\\\hline\hline}
It simply draws a table with response numbers and empty cells.
For the reference form, you need to take into account the answer number, so for each question we will draw a separate table, the contents of which correspond to the correct answer:
\def\markX{\hbox to 1cm{\hfil\bf X\hfil}} \def\@@one{\markX\\\hline\\\hline\\\hline\\} \def\@@two{\\\hline\markX\\\hline\\\hline\\} \def\@@three{\\\hline\\\hline\markX\\\hline\\} \def\@@four{\\\hline\\\hline\\\hline\markX\\} \def\the@ns#1{\hbox to 1cm{\begin{tabular}{|c}\ifcase#1\null\or\@@one\or \@@two\or\@@three\or\@@four\fi \end{tabular}}}
We identified the markX command to reduce the scribbling, the @@ one ... @@ four commands display a column table, in which the first ... fourth row is marked with an
X. The @ ns command produces the required table depending on the value of the argument - the number of the correct answer.
To fill in the reference form we use the following commands:
\def\l@@@{\ifnum\cone<\ctwo\gdef\c@ll{\the@ns{\ref{q\number\cone}}}\else\gdef\c@ll{}\fi \global\advance\cone by1\global\advance\cthree by1 \l@@n@\c@ll\ifnum\cthree<10\l@@@\fi} \def\@@tru{\global\advance\cone by-10 \global\cthree=0\hbox to 2.5cm{\begin{tabular}{|c} \hbox to 2.5cm{\hfil )\hfil}\\\hline \hbox to 2.5cm{\hfil )\hfil}\\\hline \hbox to 2.5cm{\hfil )\hfil}\\\hline \hbox to 2.5cm{\hfil )\hfil} \end{tabular}}\l@@@\\\hline\hline}
The second team directly fills the contents of the 10-question label with the correct answers; The first - recursively substitutes the required table-columns. It works almost like a team that forms a heading with question numbers, but instead of a question number it inserts a sign that shows the correct answer to this question.
For the recursive output of all tables (since we can have more than ten questions, there will be more than one table, respectively)
\def\@@tmp{\ifnum\cone<\ctwo\global\cthree=0 \l@n@\\\hline\bl@nk\@@tmp\fi}
The filling of the form is implemented by the showtbl command, which displays the table header (m @ keh @ ader), then the table body (@@ tmp) and, finally, the table base (m @ kefoot @ r):
\def\m@keh@ader{\begin{center}\begin{tabular}{||c|c|c|c|c|c|c|c|c|c|c||} \hline\hline .~&\multicolumn{10}{|c||}{ }\\\hline} \def\m@kefoot@r{\end{tabular}\end{center}} \def\showtbl{{\tabcolsep=0pt\global\ctwo=\total\global\cone=0 \m@keh@ader\@@tmp\m@kefoot@r}}
Well, to realize the construction of the reference form, we need to replace the bl @ nk command with @@ tru (so that instead of empty cells we draw cells with marks), and then do the same thing that the showtbl command did:
\def\trueans{{\tabcolsep=0pt\global\ctwo=\total\global\cone=0 \m@keh@ader\gdef\bl@nk{\@@tru}\@@tmp\m@kefoot@r}}
Everything, our style file is ready.