On Windows, how could I instruct R to call TeXlive instead of MikTeX?
I've got R set up on my Linux and Windows machines. On my Windows machines, I happen to have both MikTeX and TeXlive available. For reasons I won't go into I'd like R to call TeXlive. At this time, R is picking up MikTeX instead.
I'm guessing I would need to set TEXINPUTS inside my Renviron file, or something similar. But I haven't been able to find precise instructions online. Help will be appreciated.
UPDATE: Here are different things I tried: changing the order of TeXlive and MikTeX in the PATH. Removing MikTeX from the path. Neither worked, MikTeX is still being picked up.
I couldn't find the relevant documentation for R, but I did find some hints in the RStudio documentation, so I attempted to solve the problem within RStudio. I successfully defined the RSTUDIO_PDFLATEX environment variable:
Sys.getenv('RSTUDIO_PDFLATEX')
[1] "C:/texlive/2012/bin/win32"
[Reference: http://www.rstudio.com/ide/docs/authoring/latex_program?version=0.97.312&mode=desktop]
but MikTeX is still called upon.
Sys.which("pdflatex")
pdflatex
"C:\\PROGRA~2\\MIKTEX~1.9\\miktex\\bin\\pdflatex.exe"
UPDATE 2: Another thing I've tried: While texlive is already on my PATH, just in case I added it from within R.
Sys.setenv("PATH" = paste(Sys.getenv("PATH"),"C:/texlive/2012/bin/win32",sep=":"))
I also tried to set the path to pdflatex as returned by Sys.which("pdflatex") with the following:
Sys.setenv(pdflatex="C:/texlive/2012/bin/win32")
as well as variants with PDFLATEX or "PDFLATEX", but that doesn't help. I have also removed everything from the path except the path to texlive:
Sys.setenv("PATH" = "C:/texlive/2012/bin/win32")
That gives me the desired path
Sys.which("pdflatex")
pdflatex
"C:\\texlive\\2012\\bin\\win32\\pdflatex.exe"
However, running texi2dvi fails:
tools::texi2pdf(Out)
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
pdflatex is not available