rr-exams

Plot/image size in exams2nops and in exams2pdf without modifying the template


I have an R/exams exercise like scatterplot.Rmd and tried to include different chunk options into the exams2pdf/exams2nops command, but nothing changed the size of the included image for me:

Am I doing something wrong?

I saw that I can adapt the LaTeX template but if possible I would avoid it. Is there another way?


Solution

  • Main answer: The advice from the other answer you linked applies: How to reduce plot (image) size for `exams2pdf` output?

    Short recap:

    Additional answer: If you want to set a different Gin for the entire document (e.g., 50% of the text width), you can do this in both exams2nops() and exams2pdf() via some LaTeX code passed to the header argument.

    exams2pdf("scatterplot.Rmd", header = list(`setkeys{Gin}` = "width=0.5\\textwidth"))
    exams2nops("scatterplot.Rmd", header = "\\setkeys{Gin}{width=0.5\\textwidth}")
    

    Note: The list() specification would also work in exams2nops(). The simpler vector specification should also be supported in exams2pdf() in future versions of the package.