5

I'm currently using Rstudio and R markdown to create a pdf. However, every time I attempt to knit these error messages show up:

! Sorry, but C:\Users\AP\AppData\Local\Programs\MiKTeX\miktex\bin\x64\pdflatex.exe did not succeed.

! The log file hopefully contains the information to get MiKTeX going again:

!   C:\Users\AP\AppData\Local\MiKTeX\miktex\log\pdflatex.log

Error: LaTeX failed to compile new-report.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See c2089682-report.log for more info.
In addition: Warning message:
In has_crop_tools() : 
Tool(s) not installed or not in PATH: ghostcript
-> As a result, figure cropping will be disabled.
Execution halted

I've attempted to uninstall/re-install MiKTex and restarting Rstudio but the problem persists. How can I solve this issue?

Phil
  • 7,287
  • 3
  • 36
  • 66
RDTJr
  • 185
  • 1
  • 9
  • If you are using a Mac OS, you'll need MacTex. (Not sure on the back story, but if you're using Mac, collect MacTex via Safari, not Chrome.) If you are still looking for a solution, I suggest that you run `sessionInfo()` and add it to your question. Something as simple as an out-of-date package could be causing this. Another option could be in this question's answers may help: https://stackoverflow.com/questions/66305776/got-knit-issue-with-r – Kat Apr 15 '21 at 05:18

2 Answers2

13

With a new installation of MiKTeX, many style files needed to knit an RMarkdown file to PDF are not installed. To allow MiKTeX to install them on the fly, open the MiKTeX console and go to the Settings tab.

There is an option that says You can choose whether missing packages are to be installed automatically (on-the-fly). Make sure that this is set to Always to allow the necessary style files to be installed.

Muhammad Tariq
  • 3,318
  • 5
  • 38
  • 42
Brian Gill
  • 131
  • 3
  • Please read this https://stackoverflow.com/help/how-to-answer – Muhammad Tariq Apr 15 '21 at 05:48
  • It didn't work in my laptop. I use Windows 10 and R version 4.2.0. The error says "Sorry, but C:\Users\DELL\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe did not succeed. The log file hopefully contains the information to get MiKTeX going again: C:\Users\DELL\AppData\Local\MiKTeX\2.9\miktex\log\pdflatex.log Error: LaTeX failed to compile Ensayo.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. Ejecución interrumpida". I did check the debugging tips but non of those work. What should I do? – Ana S. H. Aug 21 '22 at 15:35
2

For me I just went to MiKTeX console setting and choose ALWAYS missing packages to be installed automatically.