5

I'm running RStudio (0.98.1091) and Texworks MiKTeX (2.9 64 bit) on Windows 7.

My PATH environment variable is set and includes the complete path to the MiKTeX directory where pdflatex lives: "F:\Tools\MiKTeX 2.9\miktex\bin\x64". If I open a command shell I can see the PATH is set; I can also invoke pdflatex simply by typing in the command shell.

I can see my PATH variable with the correct path to the MiKTeX /bin folder if I open RStudio and type Sys.getenv("PATH") in the console.

However, when I run Rmarkdown in Rstudio it complains that there's no pdflatex available.

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

  Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
  (NOTE: Be sure to download the Complete rather than Basic installation)

Google searches bring back several questions like mine, except for MacOS, like this:

https://support.rstudio.com/hc/communities/public/questions/203561546-RStudio-can-t-detect-pdflatex-No-Tex-installation-detected-

Is there any way for me to tell RStudio where MiKTeX is installed so I can generate PDFs?

  • 1
    This here support.rstudio.com/hc/communities/public/questions/… sounds as if you can use in Rstudio Sys.setenv(PATH = paste(Sys.getenv("PATH"), "p:\Git\bin", sep=.Platform$path.sep)) to add pathes. (But I don't have Rstudio so I can't say it. You could also try Sys.getenv("PATH" to find out, what value rstudio is using. – Ulrike Fischer Mar 6 '15 at 8:06
10

Ulrike Fischer's comment is correct. In RStudio for Windows, I can do this:

Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\RMathew\\PortableApps\\MikTeX\\miktex\\bin", sep=.Platform$path.sep))

which will let me use pdfLaTeX for that session. For some reason, RStudio seemed to forget this command each time I started RStudio, but this will work when you enter it.

Note the use of the double backslash for each folder.

0

If it still fails once you've set the environment PATH, I found that restarting the PC does the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.