I am rendering two documents, that cross-reference items in each other. For that I am using the LaTeX package zref
.
To make zref
work, it needs the *.aux
file of the documents which are created when calling pdflatex
.
Unfortunately, using RStudio and its basic approach to render the document (the knit button, Cmd+Shift+K or rmarkdown::render()
) these files will be deleted after the compilation was successful.
Unchecking the global option Tools -> Global Options -> Sweave -> Clean auxiliary output after compile does not help.
I know of two options to go around this:
Manually compile the tex file after the pdf was rendered.
Write a makefile that does that.
But is there another option I am not aware of?
rmarkdown::render()
eventually calls tinytex::latexmk()
to compile the intermediate .tex
to .pdf
. To preserve auxiliary files, you need tinytex::latexmk(..., clean = FALSE)
. One way to set clean = FALSE
is through the global option options(tinytex.clean = FALSE)
. You can set this in either your .Rprofile
or a code chunk of your Rmd document.
The RStudio option you mentioned is only for Sweave documents (.Rnw
).