[R] how to set the pdflatex path

annoporci annoporci at gmail.com
Wed Mar 13 14:13:09 CET 2013


Dear all,

This is my first post to the mailing list. I asked this question a little
while ago on stackoverflow but did not get an answer. Please allow me to
ask again.

I have R set up on both Windows7 and kUbuntu12 machines. On Windows, I
happen to have both MikTeX and TeXlive available (and both work).

How could I instruct R to call TeXlive instead of MikTeX?

Both MikTeX and TeXlive are on my Windows PATH.

This is what I get now:

           Sys.which("pdflatex")
                                                pdflatex
           "C:\\PROGRA~2\\MIKTEX~1.9\\miktex\\bin\\pdflatex.exe"

I tried to set pdflatex via Sys.setenv

           Sys.setenv(pdflatex="C:/texlive/2012/bin/win32")

but it doesn't seem to work in that Sys.which("pdflatex") returns MikTeX
again: (I also tried with PDFLATEX or "PDFLATEX" in the above)

The closest I've got to setting the path to pdflatex is by clearing the
PATH and including TeXlive thus:

           Sys.setenv("PATH" = "C:/texlive/2012/bin/win32")

This radical move apparently gives me the desired path:
           Sys.which("pdflatex")
                                        pdflatex
           "C:\\texlive\\2012\\bin\\win32\\pdflatex.exe"

but R still cannot find the TeXlive executables.

For instance, running texi2dvi:

           tools::texi2pdf(Out)
           Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet =
quiet,
:
           pdflatex is not available

For information, my PATH shows (edited):

           Sys.getenv("PATH")
           [1] "C:\\ ... ;C:\\Program Files (x86)\\MiKTeX
2.9\\miktex\\bin\\;C:\\texlive\\2012\\bin\\win32;..."

Changing the order of MikTeX and TeXlive in the PATH did not help R pick up
TeXlive.

Suggestions will be appreciated,

Patrick.

For reference, my question on stackoverflow:
http://stackoverflow.com/questions/15033615/setting-up-r-to-pick-up-texlive-rather-than-miktex-on-windows



More information about the R-help mailing list