问题
I have been trying to get pdflatex to use the correct version of miktex and have not been successful.
I have set the R Path to have the correct location of Miktex 2.9, and verified that it worked with:
Sys.getenv("PATH")
"C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\pdflatex;..."
However when i look at the version of miktex that pdflatex is using:
Sys.which("pdflatex")
"C:\\PROGRA~1\\MIKTEX~1.9\\miktex\\bin\\x64\\pdflatex.exe"
This 1.9 path is to an old version of miktex that no longer even exists.
Running in the command prompt which pdflatex returns the correct path, so the problem is just in R. How can I get R to use the correct path to pdflatex?
回答1:
There are couple solutions you can try:
Disable the "Enable shell escape commands" in Tools > Global Options > Sweave
Set the path manually per this answer. You will have to run this every time you restart RStudio.
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:/Program Files/MiKTeX 2.9/miktex/bin/x64", sep=.Platform$path.sep))
Put the following line in
Renviron.site
in the folderR_HOME/etc
whereR_HOME
is the path returned bySys.getenv("R_HOME")
. RefPATH=C:/Program Files/MiKTeX 2.9/miktex/bin/x64:"${PATH}"
Install tinytex package. Note that you should use either MiKTeX or
tinytex
, but not both. If you have both installed, Yihui recommended that you remove MiKTeX in this case. Ref
You might have to restart R/RStudio or even your PC/laptop after each change to see if it works or not
来源:https://stackoverflow.com/questions/51814278/set-path-to-miktex-for-pdflatex-in-r