简体   繁体   中英

Keep auxiliary TeX files when rendering a rmarkdown document

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:

  1. Manually compile the tex file after the pdf was rendered.

  2. 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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM