Search code examples
rr-exams

Add whitespace below questions for written answers in PDFs


We only have written (paper-pencil) exams, and we only have short/medium-sized string answers. In our current exams, we present the question, and leave some whitespace below (which varies depending on the expected length of the answer).

How can I flexibly add that whitespace below a question when I export a PDF from R/exams?


Solution

  • As pointed out by @jtr13 the easiest solution when all exercises get the same rule for the white space, e.g., a fixed amount or the rest of the page as shown in the post from the R-Forge forum.

    If the white space amount varies from exercise to exercise (as mentioned in the original question) then a very simple solution is to include something like

    \vspace*{5cm}
    

    in every exercise and vary the amount of white space as needed. This works in both R/Markdown (.Rmd) and R/LaTeX (.Rnw) exercises with exams2pdf(). When converting to HTML (e.g., for Moodle etc.) it is simply ignored.

    If it should be possible to optionally ignore the white space in the PDF as well (e.g., when compiling a question list as an overview rather than an exam), then I would use a custom dedicated command. This can then optionally be ignored by making the command inactive. Instead of \vspace you could use, say

    \whitespace{5cm}
    

    Then in the header of the LaTeX template you need to define the command, e.g.

    \let\whitespace=\vspace
    

    And in a template that should ignore the command you could say

    \newcommand{\whitespace}[1]{}
    

    For a concrete example of a LaTeX template see the answer by jtr13 or vignette("exams", package = "exams").