R Sweave: NO TeX installation detected

17,171

Usually Rstudio finds the correct path to your Latex installation automatically. In your case that doesn't seem to be the case. After making sure Miktex is installed correctly (have you opened it and compiled a simple file?) you can set the pdflatex path manually:

Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64", sep=.Platform$path.sep))

This is the path to my pdflatex.exe file, yours might live somewhere else.

You will have to run this every time you restart RStudio. Adding the path to pdflatex.exe to your PATH variable in Windows should make this permanent but I haven't tested that. Go to System Properties, click on Environment Variables, then on Path and then Edit. Then just enter the path to your pdflatex.exe:

enter image description here

Share:
17,171
user9084595
Author by

user9084595

Updated on August 21, 2022

Comments

  • user9084595
    user9084595 over 1 year

    I've tried searching on google to fix this, with very minimal helpful solutions.

    I have installed, Miktex, R and R studio. I would like to use Sweave to create PDF documents in Miktex. Everytime I open my .Rnw file, it gives a warning at the top which reads "No TeX installation detected. Please install TeX before compiling"

    When I look for pdflatex on my system with the command Sys.which("pdflatex") it returns ""

    Does anyone know how to fix this? ANYTHING at all at this point would be useful.