Bookdown: Different classoptions of pdf_book and beamer_presentation2

It is possible to use classoption in the YAML header of a RMarkdown document, to adjust output to LaTeX.
Making global settings with classoption works fine for me, but I would for example like to use the aspectratio=43 classoption for only for beamer_presentation2 and not pdf_book output.

I tried to move the classoption below the document like in

bookdown::beamer_presentation2
  classoption: aspectratio=43

but this doesn't work.

I'm actually already struggling in identifying whether this is a pandoc or a bookdown problem.

Unfortunately, rmarkdown does not allow that. classoption is a Pandoc option and needs to be provided at top level. If you want to provide it at the output format level, it is not straighforward in rmarkdown but probably still possible by passing it as a Variable pandoc flag in pandoc_args argument.

FYI, new tool Quarto https://quarto.org (next generation of R Markdown) solves this problem, by allowing Pandoc's variables to be passed at format level.

1 Like

Thanks a lot for your clarification, which helped me to find a nice solution:
By adding

 pandoc_args:
      - --metadata=classoption:aspectratio=43

gives me exactly what I was looking for.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.