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:
height = 50, width = 50height = 5, width = 5height = 0.5, width = 0.5fig.height = 0.5, fig.width = 0.5out.width = 0.5Am I doing something wrong?
I saw that I can adapt the LaTeX template but if possible I would avoid it. Is there another way?
Main answer: The advice from the other answer you linked applies: How to reduce plot (image) size for `exams2pdf` output?
Short recap:
fig.height and fig.width you only control the size of the graphics file which has an influence on the relative size of the annotation etc.Gin keys.plain.tex template used in exams2pdf() graphics are included with 80% of the text width because the template sets \setkeys{Gin}{width=0.8\textwidth}. You can copy and modify the template if you want to use other options.exams2nops() no Gin is set so that graphics files are included "as is" (and thus fig.height and fig.width have a direct effect on the relative size as well).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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With