0

I'm using an R Sweave doc and trying to compile a pdf from RStudio using TinyTex. Let's assume my Sweave file is titled "Example.Rnw" and my file path to the .tex output is "Path/Example.tex." After hitting "Compile PDF" in my Sweave doc, I get the following error:

[1] "Example.tex"
Compiling document with tinytex ... Error: LaTeX failed to compile /Path/Example.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
Execution halted
failed
Error running /usr/local/bin/pdflatex (exit code 1)

When I copy and paste the resulting .tex file into Overleaf, the pdf looks fine. My guess is there's some issue with pdflatex and TinyTex, but I'm not sure what. After a few hours I'm still stumped. Any advice for how to compile this pdf? I've already updated and reinstalled TinyTex, and set my PATH to the TinyTex distribution folder. Thanks in advance.

Steve K
  • 41
  • 4
  • 1
    Can you show the .tex file so we can test if it compiles? (overleaf is notoriously good at hiding error messages) – samcarter_is_at_topanswers.xyz Nov 23 '21 at 20:36
  • Can confirm it compiles. I can also produce the pdf from Terminal using "pdflatex," but for some reason I run into the above error when trying to use "compile pdf" from RStudio. – Steve K Dec 09 '21 at 03:55
  • From the cross-posted issue at https://github.com/yihui/tinytex/issues/348, when you compile from the Terminal, it seems to be using `~/Library/TinyTeX/bin/universal-darwin/pdflatex`, whereas here in the error message, it says that it was using `/usr/local/bin/pdflatex`. My guess is that the latter is broken somehow. Try to run `tinytex::tlmgr_path()` in R if `ls -l /usr/local/bin/pdflatex` in the Terminal shows that this `pdflatex` is not a symlink to the `pdflatex` in `~/Library/TinyTeX/...`. – Yihui Xie Dec 09 '21 at 04:54
  • Thanks Yihui. I've since changed my PATH between the above Stack Overflow post and the GitHub issue opened yesterday. I followed your directions and ran `ls -l /usr/local/bin/pdflatex` in Terminal, which produced an output of `lrwxr-xr-x 1 stevenkoller admin 65 Dec 9 10:19 /usr/local/bin/pdflatex -> /Users/stevenkoller/Library/TinyTeX/bin/universal-darwin/pdflatex`. Also ran `tinytex::tlmgr_path()` in RStudio, but the compilation still fails. Not sure what the disconnect is between RStudio and pdflatex. – Steve K Dec 09 '21 at 15:25
  • I have no idea about what could possibly have gone wrong in this case. My last suggestion is to try check the option "Options -> Global Options -> Sweave -> Use tinytex when compiling .tex files`. If this still doesn't work, you may uninstall TinyTeX and try other LaTeX distributions. – Yihui Xie Jan 25 '22 at 20:47

0 Answers0