object pdflatex not found on Windows 7

10.8k views Asked by At

I work with RStudio (version 3.1.2). When I try to Knit PDF in my R Markdown script, I receive the following output:

Error in eval(expr,envir,enclos): object 'pdflatex' not found

I have installed MikTex basic and have searched solutions on the web. There is one in stackoverflow for Mac users, I work with Windows 7. It seems the problem is not having a path to the Tex installation. I found this brief guide to solve it on Windows: enter link description here

So, I did what it says: Sys.which("pdflatex") and received:

pdflatex

  ""

Ten I typed: Sys.getenv("PATH"), obtaining:

1 "C:\Program Files\R\R-3.1.2\bin\x64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;:/usr/texbin:/usr/texbin"

Finally, I entered: Sys.setenv(PATH=paste(Sys.getenv("PATH"),"/usr/texbin",sep=":")), but when I try to knit PDF again it shows me the same error message. Thanks for all your time, I would appreciate any help.

3

There are 3 answers

0
Thomas On

Edit your PATH variable. You're on windows, but you've tried to add a UNIX-style directory (i.e., separated from the other directories by : and using / rather than \). '/usr/texbin/' is probably not a directory on your computer.

0
kategorically On

I'm working on a 64 bit Windows, so the Sys.which("pdflatex") returned:

 C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe

Type in sessionInfo(). You should se something like this:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

Depending on your system the path could be either: C:\Program Files\MiKTeX 2.9\miktex\bin (for the 32-bit version) or C:\Program Files\MiKTeX 2.9\miktex\bin\x64 (for the 64-bit version).

0
Martin On

Check your path. It might look like this C:\Program Files\MiKTeX 2.9\miktex\bin\x64 assuming you're working on a x64 OS. After that, open a cmd console and check if is everthing ok with this command: pdflatex.exe -version. Then restart RStudio and try to render your pdf again.