0
votes

I am trying to knit a simple markdown file to a pdf using knitr and R Studio. The chunks all run fine and I have no problems knitting to an HTML document, but get the following error when trying to knit to a pdf:

! LaTeX Error: File `knitr.sty' not found.

I have reinstalled tinytex and made sure that the knitr and rmarkdown packages are up to date. I've looked around and while there are similar issue with other *.sty files, I can't find anything relating to this one.

Thanks in advance for any advice

1
Can't remember the exact setting but there should be something like "update packages o n the fly" which solves such issues? - NelsonGon
Where is this setting? In R Studio, Tinytex or Knitr? - Roger Hill
Probably tinytex. Just a checkbox. See this: bookdown.org/yihui/rmarkdown-cookbook/install-latex-pkgs.html - NelsonGon
This error should only occur when you use .Rtex documents (see stackoverflow.com/questions/67250207/…), but you said you were knitting Markdown. I can't think of a possible reason why this could occur for Markdown documents. Would you please provide a minimal reprex? And @NelsonGon tinytex won't solve the problem because knitr.sty is not from a LaTeX package from CTAN. - Yihui Xie
Hi Yihui, thanks for the reply. As a test, I've cut my file down so it only includes ordinary text and basic Latex code. Would it help if I sent you the log file? - Roger Hill

1 Answers

0
votes

Solved this: for some reason I had listed several R packages in the 'extra_dependencies' part of the YAML metadata. Once removed it worked.