Search code examples
rr-markdownr-exams

Answerlist with two columns only on specific questions


Is there a way of specifying an answerlist with two columns directly in the .rmd question?

I am preparing a single choice pdf exam using R exams exams2pdf(myexam, n=1) with answer lists containing either only texts or only images, and I would like to make some questions with the answerlist in a two-column layout (e.g. only questions that contain images). I've seen the possibility of changing the template, but that would change the layout for all questions.

  ```{r, echo = FALSE, results = "hide"}
     exams::include_supplement("a.jpg")
     exams::include_supplement("b.jpg")
     exams::include_supplement("c.jpg")
     exams::include_supplement("d.jpg")
  ```
Question
========
What is the seat of the federal authorities in Switzerland (i.e., the de facto capital)

Answerlist
----------
* ![](a.jpg){width=10%}
* ![](b.jpg){width=10%}
* ![](c.jpg){width=10%}
* ![](d.jpg){width=10%}

Meta-information
================
exname: Swiss Capital
extype: schoice
exsolution: 0100
exshuffle: 4

pdf outcome using exams2pdf(myexam, n=1)


Solution

  • It is not impossible to do this but the system is not designed to switch the layout back and forth between the exercises.

    If you want to do this you would need to set up a LaTeX template that manually includes all the individual exercises and re-defines the {answerlist} environment between those exercises where you switch. The downside is that if you change the order and/or number of the exercises you always have to modify the LaTeX template. Hence I would not recommend to use this approach. For an example how a multi-column {answerlist} can be set up, see the plain-horiz.tex template from the R-Forge forum.

    A simpler option is to generate a table of figures in the main question text and then to include only the numbers/labels of those figures in the answerlist. A worked example for this is available in the logic exercise.

    (One caveat, though: It depends on the pandoc version how the table is rendered exactly. The most recent versions of pandoc are not compatible with the default LaTeX template from R/exams.)