I am preparing a cloze
question using exams2pdf()
from R/exams, where the students are asked to fill in two 4 x 4 matrices. That makes too many (32) questions, and LaTeX complains about it ! LaTeX Error: Counter too large.
I have tried to change the environment answerlist
in the *.tex
solution template using arabic
instead of alph
(default), i.e. from
\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\alph{enumi})}\begin{enumerate}}{\end{enumerate}}
to
\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\arabic{enumi})}\begin{enumerate}}{\end{enumerate}}
but I still get the same error.
UPDATED
I provide a MWE in .Rnw
format
<<echo=FALSE, results=hide>>=
M1 <- matrix(rep(1, 16), ncol = 4)
M2 <- matrix(rep(2, 16), ncol = 4)
nsol <- 32
questions <- solutions <- explanations <- points <- type <- rep(list(""), nsol)
points[] <- rep(1, nsol)
explanations[] <- solutions[] <- c(pracma::Reshape(a = M1, n = 16, m = 1), pracma::Reshape(a = M2, n = 16, m = 1))
tol <- num_to_tol(unlist(solutions), reltol = 0.01, min = 0.01, digits = 2)
explanations[] <- solutions[] <- round(unlist(solutions), 2)
questions[] <- rep("", nsol)
type[] <- rep("num", nsol)
@
\begin{question}
\begin{enumerate}
\item Find matrix $M_1$
\begin{tabular}{|cccc|}
~##ANSWER1##~ & ~##ANSWER5##~ & ~##ANSWER9##~ & ~##ANSWER13##~ \\
~##ANSWER2##~ & ~##ANSWER6##~ & ~##ANSWER10##~ & ~##ANSWER14##~ \\
~##ANSWER3##~ & ~##ANSWER7##~ & ~##ANSWER11##~ & ~##ANSWER15##~ \\
~##ANSWER4##~ & ~##ANSWER8##~ & ~##ANSWER12##~ & ~##ANSWER16##~ \\
\end{tabular}
\item and $M_2$
\begin{tabular}{|cccc|}
~##ANSWER17##~ & ~##ANSWER21##~ & ~##ANSWER25##~ & ~##ANSWER29##~ \\
~##ANSWER18##~ & ~##ANSWER22##~ & ~##ANSWER26##~ & ~##ANSWER30##~ \\
~##ANSWER19##~ & ~##ANSWER23##~ & ~##ANSWER27##~ & ~##ANSWER31##~ \\
~##ANSWER20##~ & ~##ANSWER24##~ & ~##ANSWER28##~ & ~##ANSWER32##~ \\
\end{tabular}
\end{enumerate}
<<echo=FALSE, results=hide, results=tex>>=
answerlist(unlist(questions))
@
\end{question}
%% META-INFORMATION
%% \exname{Frustum}
%% \exsection{Tema 4/frustum}
%% \extitle{Tema 4. Frustum}
%% \exversion{0.2}
%% \extype{cloze}
%% \exclozetype{\Sexpr{paste(type, collapse = "|")}}
%% \expoints{\Sexpr{paste(points, collapse = "|")}}
%% \exsolution{\Sexpr{paste(solutions, collapse = "|")}}
%% \extol{\Sexpr{paste(tol, collapse = "|")}}
%% \exextra[numwidth,logical]{TRUE}
Moodle:
If you are asking about two matrices, then I wouldn't use the standard itemized display but use a cloze with ##ANSWERi##
placeholders and then format the matrices as tables. A worked dummy example is included below and using exams2moodle("matrices.Rmd")
works without error and leads to the following display in Moodle:
PDF:
Running exams2pdf("matrices.Rmd")
also works without error. However, I'm not sure whether this is the display you want or how you would want to administer the PDF version of the exercise. Or is this just for your reference?
Exercise code:
The R/Markdown code for the matrices.Rmd
file is provided below. For a similar table-based exercise see the fourfold2 exercise template on the R/exams web page. This also includes an R/LaTeX version of the exercise.
Question
========
Fill the following 4x4 matrix with the numbers 1 to 16 (by column):
| | 1 | 2 | 3 | 4 |
|--:|-----------------:|-----------------:|-----------------:|-----------------:|
| 1 | \#\#ANSWER1\#\# | \#\#ANSWER5\#\# | \#\#ANSWER9\#\# | \#\#ANSWER13\#\# |
| 2 | \#\#ANSWER2\#\# | \#\#ANSWER6\#\# | \#\#ANSWER10\#\# | \#\#ANSWER14\#\# |
| 3 | \#\#ANSWER3\#\# | \#\#ANSWER7\#\# | \#\#ANSWER11\#\# | \#\#ANSWER15\#\# |
| 4 | \#\#ANSWER4\#\# | \#\#ANSWER8\#\# | \#\#ANSWER12\#\# | \#\#ANSWER16\#\# |
Fill the following 4x4 matrix with the numbers 17 to 32 (by column):
| | 1 | 2 | 3 | 4 |
|--:|-----------------:|-----------------:|-----------------:|-----------------:|
| 1 | \#\#ANSWER17\#\# | \#\#ANSWER21\#\# | \#\#ANSWER25\#\# | \#\#ANSWER29\#\# |
| 2 | \#\#ANSWER18\#\# | \#\#ANSWER22\#\# | \#\#ANSWER26\#\# | \#\#ANSWER30\#\# |
| 3 | \#\#ANSWER19\#\# | \#\#ANSWER23\#\# | \#\#ANSWER27\#\# | \#\#ANSWER31\#\# |
| 4 | \#\#ANSWER20\#\# | \#\#ANSWER24\#\# | \#\#ANSWER28\#\# | \#\#ANSWER32\#\# |
```{r questionlist, echo = FALSE, results = "asis"}
answerlist(rep("", 32), markup = "markdown")
```
Meta-information
================
exname: matrices
extype: cloze
exsolution: 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32
exclozetype: num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num|num
exextra[numwidth,logical]: TRUE