Using R, RStudio Knit to PDF, how to pass custom flags to the "pdflatex" command such as -interaction=nonstopmode

198 Views Asked by At

I am coming to RStudio from the CMD prompt and the pdflatex command. From my understanding, RStudio runs behind the scenes:

  • pdflatex
  • bibtex (if you have natbib going on)
  • pdflatex

I would like to be able to pass some parameters like "-quiet" or "-interaction=nonstopmode"

enter image description here

From the command line, these are possible.

How do I add custom flags to the RStudio implementation of pdflatex?

1

There are 1 best solutions below

0
user2554330 On

You don't say, but I'll assume you're working in R Markdown. For R Markdown, RStudio gets pandoc to call pdflatex. From the Pandoc manual, you want to set the Pandoc option --pdf-engine-opt: see https://pandoc.org/MANUAL.html#option--pdf-engine-opt. To do this in an RMarkdown document, you put this in the header:

output:
  pdf_document:
    pandoc_args:  "--pdf-engine-opt=-quiet"

If you want multiple arguments I think you can just include them in the string, but you might need to do it like this:

output:
  pdf_document:
    pandoc_args:  ["--pdf-engine-opt=-quiet",
                   "--pdf-engine-opt=-interaction=nonstopmode"]

You'll have to try it to see which works for you; both are accepted, but I couldn't tell if they were both being acted on.