I am using exams2pdf()
to generate two PDF files as:
exams2pdf(file = "ICvar.Rmd",
name = "icvar",
engine = "knitr",
verbose = FALSE,
texdir = "tmptex",
template = c("exam", "solution")
)
But I get this error:
Error in base::file(out_tex[j], open = "w+", encoding = encoding) : invalid 'description' argument
Any ideas why?
Also, is it possible to use custom templates in exams2nops()
like template = c("exam", "solution")
to produce two PDF files, the first with the questions; the second with the solutions? I read the vignette but could not find any information and adding template to options in exams2nops()
does nothing.
The problem is that you only provide a single name = "icvar"
but actually need two distinct name
s for template = "exam"
and template = "solution"
, respectively. Hence, lacking a second name
lead to the somewhat cryptic error message. A simple solution is to provide a vector of two name = c("icex", "icsol")
, say.
Additionally, I have just committed a fix to the development version on R-Forge that points this out more clearly in ?exams2pdf
, throws an intelligible warning, and provides a workaround. If you use your code above, name
is changed to name = c("icvar_exam", "icvar_solution")
automatically.
As for exams2nops()
: Internally this essentially sets up a standardized template
via make_nops_template()
and then calls exams2pdf()
. No additional templates can be provided. The reason for this is that all the convenient options in the NOPS template (e.g., adding an intro
, selecting the language
, switching to twocolumn
layout, etc.) would only work for the NOPS template but not the other templates provided. Therefore, if you want to produce a solution sheet you have to use another call to exams2pdf()
(or exams2html()
or exams2pandoc()
) after setting the same random seeds as for exams2nops()
.