Where is the .tex file kept when compiling Rmd in Rstudio server
Asked Answered
V

2

6

This may sound like a dumb question, but I'd like to know where is the .tex file saved, when I compile a pdf document from a Rmd file, using RStudio server. I added the keep_tex option, so the header of Rmd looks like this :

---
output:
  pdf_document:
    keep_tex: yes
---

Then when I compiled, the output looks like this

  |......................                                           |  33%
  ordinary text without R code

  |...........................................                      |  67%
label: plot


processing file: test.Rmd
cropping /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test_files/figure-latex/plot-1.pdf
PDFCROP 1.33, 2012/02/01 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `/tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test_files/figure-latex/plot-1.pdf'.
  |.................................................................| 100%
  ordinary text without R code


/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in' 
output file: test.knit.md

/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.pdf --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in' 

Output created: /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.pdf

I'd like to find the intermediate .tex file (or test.knit.md), and do a bit of editing. Except it is no where to be found. Not in the working directory, or /home/myusername/, or /, or /tmp/Rtmpb1x3Q0/. I'd really appreciate it if someone has the answer.

Voltcoulomb answered 30/4, 2015 at 15:33 Comment(1)
This does not answer completely the question, but I found a workaround to at least get the pdf file generated by knitr. Previously I previewed the pdf in the Rstudio PDF viewer. By changing to the system viewer in global options, I can now save the pdf file generated.Voltcoulomb
V
3

Actually, this first line in the console

/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from       markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in' 

told us that the output .tex file is in /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex Somehow I did not find the file last time, but on a recent instance, the .tex file is actually there, so that answers the question.

Voltcoulomb answered 22/6, 2015 at 9:7 Comment(2)
I found it. Is there a way to save the Latex files somewhere else? Say where you also save the rmarkdown file?Divest
@Divest If you still want to know, one answer is to use the rmarkdown::render command from the Console rather than Rstudio's knit function.Monocular
T
0

The initial code from the question

---
output:
  pdf_document:
    keep_tex: yes
---

Throws an error for me, while the following does not:

---
output:
  pdf_document: default
  keep_tex: T
---

However, I was still unable to find the .tex file following the console output. It appears to still not be saved. Instead what worked easily was running the following lines in the R studio console:

#install.packages(rmarkdown)
rmarkdown::render("FileName.Rmd", output_format = latex_document())

The file "FileName.Rmd" needs to be in the current working directory - which is where the .tex file will be saved.

Thain answered 29/5, 2021 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.