object pdflatex not found on Windows 7

NuValue picture NuValue · Nov 18, 2014 · Viewed 10.7k times · Source

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.

Answer

kategorically picture kategorically · Nov 21, 2014

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).