R and Rstudio using wrong pdflatex

Viewed 754

I've googled a ton on this and can't seem to find a solution: I have Miktex 2.9 as my LaTeX environment (and I want to run pdflatex), but I can't get R to use it. Here are the R variables:

> Sys.which("pdflatex")
                                                  pdflatex 
"C:\\PROGRA~1\\MIKTEX~1.9\\miktex\\bin\\x64\\pdflatex.exe" 
> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-3.3.2\\bin\\x64;...C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\Program F...

I truncated the PATH above, but it has MiKTeX 2.9 and DOESN'T have MIKTEX 1.9 on it. I checked my environment variables and there are no pdflatex-specific variables on it.

More confusingly, when I run pdflatex from the command line or from ess in emacs it runs the right program, so this seems to be R-specific.

I guess my question is where does R/Rstudio pull the system command for pdflatex?

EDIT (SOLVED!):

In true stackoverflow fashion I found the problem after sending my question. I had to check Tools > Options > Sweave > "Enable shell escape commands" and it worked fine.

I'm still curious about why Sys.which("pdflatex") looks like it's pointing at a non-existent directory, but there's a chance that's it's actually pointing at the right directory and Windows is just screwing up the truncation of the directory when printing it.

0 Answers
Related