Q:

R tools::texi2pdf output in different folder

I am using knitr to produce a .tex file and then using tools::texi2pdf to compile it into a PDF. I get the PDF and the all the auxiliary files in the same working directory. Is there any way to change that and make the output and auxiliary files show up in a different folder?
Code example:
src = normalizePath('example.Rnw', winslash = "/")
outTex = "example.tex"
outTexFile = knit(src, output = outTex, quiet = T, envir = e)
buff = tools::texi2pdf(file = outTexFile)

Then all the files example.pdf, example.aux, example.log, etc... all show up in the working directory.
I could do a copy in the code, but I was wondering if there is a native way to have this.

A:

this solves my problem. Set the output = "folderout/example.tex" in knit2pdf. Also change the options of knitr to opts_knit$set(base.dir = normalizePath("./folderout")) see github.com/yihui/knitr/issues/530 for more details

