### Post

2 followers Follow

# pdflatex not working

Hi Josh,

I am using Windows version 7, Rstudio version 0.97.173, and MikTeX version 2.9

When compiling my PDF document, using knitr, I get the following error:
Running pdflatex.exe on plots.tex...failed Error running C:/PROGRA~1/MIKTEX~1.9/miktex/bin/pdflatex.exe (exit code 1)

I know that others have had this error, but my search of the discussion board has not directly solved my problem. I think that the path is incorrect , because it appears that RStudio is looking for MIKTEX version 1.9 -- how can I change this in RStudio (so that it will search for version 2.9)?

Thank you,
Bonnie

PS Nick H. says 'hi' (he is sitting next to me in a meeting ;-)

Ian Pylvainen

Bonnie,

Thanks for reporting and I don't think the path pointing to version 1.9 is the issue. Strangely that is the same on my system and has been for awhile (I believe it is a TeX problem that actually doesn't seem to cause any issues).

Also this issue is hard to track down on different systems. Are you able to compile this TeX document outside of RStudio? Most often it is a TeX error. If not, are you able to compile a simple "Hello World" TeX document? If that works, then it is definitely the specific file.

Let me know what you are able to find out.

Josh

P.S. Please extend my best to Nick as well. :-)

Hi Josh,

Thank you so much for your response. I actually am able to compile the text document in TeXworks - just not through RStudio.

Hello World does not work either, so it is not a Tex error.

Bonnie

Bonnie,

Can you tell me the output of the following command in RStudio:

``````> Sys.which('pdflatex')
``````

Also what do you have set for your preferences for Sweave when going to Tools | Options. Can you take a screenshot of this?

Josh

Sys.which('pdflatex')
pdflatex
"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\pdflatex.exe"

Thank you.

Bonnie,

Can you try disabling the "Enable shell escape commands" preference and then compiling a "hello world" example again? If that works, then try the more complicated, "real" example that you have. Not sure if this is reliant upon shell escape commands or not. If this proves to be the problem, I think there might be a bug on our side.

Josh

It worked!!

Yea!

Bonnie

Bonnie,

Great to hear! Thanks for the update and we'll have to take a closer look at this.

Josh

Hello I had exactly the same error from R sweave, after running my code, the error was: C:/PROGRA~1/MIKTEX~1.9/miktex/bin/pdflatex.exe (exit code 1)

I was compiling a project with output of Rstudio.

After taking time to try many ways, I found that the problem was coming from my database (the database came from yahoo). So after I upload another database (the same I had), the problem is solved and I could run my pdf.  maybe I made false manipulations in the database this is why

Hope I will help some of you.