简体   繁体   中英

RMarkdown render from command line and clear .tex intermediate output

I'm using rmarkdown::render outside RStudio to knit a .pdf document. This is working fine but it leaves behind an intermediate .tex file that I don't want. I'm already using the clear = TRUE option for rmarkdown::render . I don't know what RStudio does but it does clear the .tex file when I knit the document from the IDE.

keep_tex: false is indeed the way to go. You did not provide enough information for us to diagnose the problem.

library(rmarkdown)
temp_dir <- tempdir()

rmd <- '---
title: "Sample Document"
output:
  pdf_document:
    keep_tex: true
---'
cat(rmd, file = file.path(temp_dir, "keep_tex_true.rmd"))
render(file.path(temp_dir, "keep_tex_true.rmd"))
list.files(temp_dir)
# [1] "keep_tex_true.pdf" "keep_tex_true.rmd" "keep_tex_true.tex"

rmd <- '---
title: "Sample Document"
output:
  pdf_document:
    keep_tex: false
---'
cat(rmd, file = file.path(temp_dir, "keep_tex_false.rmd"))
render(file.path(temp_dir, "keep_tex_false.rmd"))
list.files(temp_dir)
# [1] "keep_tex_false.pdf" "keep_tex_false.rmd" "keep_tex_true.pdf" 
# [4] "keep_tex_true.rmd"  "keep_tex_true.tex" 

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