I would like to know how I can set the pdflatex path in R
to use sweave
. Because I have 2 different MikTeX installations and one is working properly. Please take into account that I am using R (RStudio) in Windows
. I found some suggestion however, for Linux or Unix users.
thanks in advance
If you have multiple installs of LaTeX (i.e. MikTeX) and you want to use a specific one of these, then you need to make sure that R finds the one you need first. This means that you have to add the location of your preferred version of pdfLaTeX at the front of your PATH system environment variable.
If you do not have administrator rights in Windows, then you can use R's environment file to change the PATH variable for R only. See
?Startup
in R for details on this process. Follow the following steps:Sys.getenv("R_ENVIRON")
. This will return the full path to an existing environment file, but will be empty in most cases. If a file exists, skip to step 3 below.PATH=C:\\full\\path\\to\\the\\folder\\with\\pdflatex;"${PATH}"
(the quotations marks are important)Sys.getenv("PATH")
andSys.which("pdflatex")
returns the correct paths.If you do not have rights to create a Renviron.site file in R_HOME\etc, then you can also create a .Renviron file in HOME (
Sys.getenv("HOME")
).