Modify latex template in Rmarkdown

Can I modify the default Latex template used by Rmarkdown to compile Rmd files to pdf with the beamer class?
I am asking because of the difficulties I encounter using \includepdf (from the pdfpages package). Inspecting the generated tex source suggests that the root problem is the ignorenonframetext option in \documentclass[ignorenonframetext,]{beamer}.
(It is not a viable option for me to manually change the tex source each time)

In short: I want to modify the "Rmd beamer Latex template" (if that exists) to change the default ignorenonframetext

Hi, welcome!

Everything that rmarkdown does goes through knitr and pandoc. In the yaml, you can specify a fair amount of LaTeX arguments, I've gone as far as including Haskell parsers to get LaTeX tables right.

You'll notice at the end of knit the command string that puts the whole chain together:

/usr/local/bin/pandoc +RTS -K512m -RTS tcase.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output tcase.tex --template /Library/Frameworks/R.framework/Versions/3.6/Resources/library/tufte/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex --highlight-style pygments --pdf-engine pdflatex --variable 'documentclass:tufte-handout'

So, I fear, what you will have to do is to add a LaTeX document class where /Library/Frameworks/R.framework/Versions/3.6/Resources/library/tufte/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex --highlight-style pygments --pdf-engine pdflatex --variable 'documentclass:tufte-handout appears.

That, I think is the sound position for a template you expect to use a lot. I find it a lot easier to write scripts using bash tools or Python to batch correct the offending option you found if I only expect to be processing this format a few dozen times. Writing LaTeX templates is not what I want to spend my time doing if possible.

Rmarkdown uses the default pandoc beamer template. You can find the mechanism in this function

pandoc -D beamer is a way to get the template. (see MANUAL) You see that rmarkdown already patch it. I guess you could to the same in your way.

  1. Get the pandoc beamer template and write it in a file
  2. modify by hand what you want
  3. pass the template to beamer_presentation function in the template argument

You could also try out binb :package:

There may be already there a template that suits you

hope it helps

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