Search code examples
latexr-exams

Use exams2pdf or a modified solution.tex template to print solutions not another answer list


I am trying to create a solution pdf for an exam but all I need for it is a simple marked box and not the answer list that follows. For example, I just want the first page from the following compilation and nothing else.

library(exams)

exams2pdf(list(
  "boxplots",
  c("tstat", "ttest", "confint"),
  c("regression", "anova"),
  "scatterplot",
  "relfreq"
), template = "solution"
)

I don't have a strong grasp of the Latex language so when I try removing for example

\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\alph{enumi})}\begin{enumerate}}{\end{enumerate}}

or

% \exinput{exercises}

It doesn't compile and just complains about a missing item etc

Which part of solution.tex can I remove that retains just the first page?


Solution

  • Solution: You need to delete all of the following lines from your copy of solution.tex:

    \newpage
    
    \begin{enumerate}
    
    %% \exinput{exercises}
    
    \end{enumerate}
    

    Details: This LaTeX code starts a new page and includes an enumerated list for the individual exercises. The \exinput{exercises} is replaced with each of the {question} (and optionally {solution}) environments which then produces an \item for each question. So if you just remove the \exinput line, LaTeX complains about missing items because the {enumerate} list is empty.

    Documentation: More details for exams2pdf() and its LaTeX templates can be found in vignette("exams", package = "exams").