RStudio can't find pdflatex - no MIKTEX, or TinyTeX

Hello, I'm sorry if this is an easy fix I'm just new to all this. So I am trying to compile code to pdf in rstudio but I keep getting the error message:

"Running pdflatex.exe on MTH366_Week1_IC1.tex...failed
Error running C:/Users/jsnyd/AppData/Local/Programs/MIKTEX~1.9/miktex/bin/x64/pdflatex.exe (exit code 1)"

I noticed that it's looking for pdflatex in a folder named MIKTEX~1.9 which does not even exist. Is there a way I can change it so that it looks in the correct folder? I have looked up the issue and tried some fixes from stack overflow but none have worked so far. I am on Windows 10 by the way if that helps.

Thank you for any help you can provide!

1 Like

Hi, and welcome!

Quick overview of the chain to create PDF:

rmarkdown -> pandoc -> MIKTEX -> pdf

The rmarkdown takes care of installing pandoc, but it's up to the user to install MIKTEX (in WinWorld) where it's expected.

The POLR (path of least resistance) here is to move pdflatex.exe to C:/Users/jsnyd/AppData/Local/Programs/MIKTEX~1.9/miktex/bin/x64, along with any other files in its current directory. (I'd be more precise, but I haven't been troubled with Windows since XP.)

1 Like

Thank you for the response!

I tried what you said and am still coming back with the same error message. The weird thing is I've tried this on two different computers and had the same problem with both.

1 Like

One possibility (again, taking into account that I've been WIN-free for a long, long time after returning to my happy place in *nix), is that read/execute permission equivalents are not properly set.

1 Like

If you don't need to particularly stick to Miktex, I would advice to use TinyTex distribution that is known to work well with Rmarkdown

In case it may help

3 Likes

Thank you for the suggestion!

After installing TinyTeX and hitting compile PDF in RStudio I'm getting a different error message that reads

"! LaTeX Error: File `epstopdf.sty' not found."

However I no longer have the previous error message so maybe it is progress?

This is discussed in the link @cderv provided. The error indicates a missing \LaTeX package (not an R package!).

To check if you have it

$ tlmgr search --global --file "/epstopdf.sty"

and to install it if you don't

$ tlmgr install epstopdf

Thank you for pointing that out. It's funny how it said "don't panic" and I ended up skipping over it in my panicking... It works great now. Just to be more specific if anyone else encounters the same problem, the package is:

tlmgr install epstopdf-pkg

This worked for me thank you very much for your help!

Great. Please mark the solution for the benefit of those to follow. It's fine to leave it as is unless you think your working code is more useful (no false modesty!)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.