I'm creating a written exam and am having trouble getting exams2pandoc() to include PNG question images in the word docx output. When I test with exams2html() instead, it successfully includes the images. Is there something I'm missing here?
My rmd files look like this:
Question
========
Susanne ist die einzige Herstellerin für Schokolade aus Schafsmilch. Die Kosten der Gesamtherstellung betragen C(q)=5q. Täglich kommen an ihrem Laden 10 Personen vorbei. Die entsprechenden Reservationspreise sind in der folgenden Tabelle dargestellt. Susanne kennt zwar die Verteilung der Reservationspreise, sie weiß jedoch nicht, wem welcher Reservationspreis zuzuordnen ist. Welche der folgenden Aussagen ist richtig?
```{r, echo = FALSE, results = "hide"}
include_supplement("2018117.PNG",
dir = "D:/institut/exam_bank/02_input/01_content/02_images", recursive = TRUE)
```
\

Answerlist
----------
* Der von Susanne gewählte Preis maximiert die Wohlfahrt.
* Susanne verkauft ihre Schokolade an Personen A, B, C, D und E.
* Um ihren Gewinn zu maximieren setzt Susanne P = C(q).
* Die Konsumentenrente bei Susannes gewinnmaximierendem Preis beträgt 15€.
* Susannes Gewinn beträgt 9€.
Solution
========
ID: 2018117,
Korrekt: E,
Thema1: 8,
Thema2: ,
Qualität: NA,
Übungsaufgabe: NA,
Gescheitert: NA,
ParentID: NA
Meta-information
================
exname: 2018117
extype: schoice
exsolution: 00001
exsection: 8,
exshuffle: FALSE
And when I do:
## Generate initial exam draw word docx
set.seed(sd)
exams2pandoc(draft, dir = paste0(path0, draftop_dir), n = 1, name = paste0("exam_", year, date, "_DRAFT_sd", sd, "_"), nsamp = 1, type = "docx", question = "" , solution = FALSE)
The docx output has no images, even though the html output does when I do:
set.seed(sd)
exams2html(draft, dir = paste0(path0, draftop_dir), n = 1, name = paste0("exam_", year, date, "_DRAFT_sd", sd, "_"), nsamp = 1, question = "" , solution = FALSE) # without solutions
Details:
Thanks for pointing out this bug. It was caused by pandoc introducing a new LaTeX macro \pandocbounded{} that the default LaTeX template in exams2pandoc() did not support yet. (For the general problem see this description in GitHub projects #1 and #2.)
Workaround:
Instead of using the default LaTeX template you can also use the HTML template that is shipped with exams2pandoc() which avoids the problem:
exams2pandoc(draft, template = "plain.html", ...)
Fix:
In version 2.4-3 of R/exams (released on CRAN in December 2025) the default LaTeX template is also fixed. With that version it is possible again to use
exams2pandoc(draft, ...)