Clicking "Compile PDF" on a tex file fails to install TeX packages

Hey, I'm trying to make a super simple workflow to show some less technical users how to use R Studio to build TeX documents. One weird thing I'm running into is on a fresh install I typically don't have all the TeX packages we need there by default. So when a user clicks the "Compile PDF" button they get a failure because of missing packages.

However if they manually run

tinytex::pdflatex("C:\\sometexfile.tex")

If that file has dependencies then pdflatex will automagically install missing dependencies. Then next time they can just click the button. Is there a setting I can change that will make the button just install dependencies? It's a bit clunky to have to one process the first time then a different process after that. Are there other ways I can work around this?

Thanks for the tip. I did not realize Yihui had built auto-install into tinytex::pdflatex. That is helpful.

As a fallback, LaTeX usually fails with name.sty not found. In a pinch users can use tlmgr install name to get going. LaTeX oddities are one of the main reasons I vastly prefer Rmarkdown...

Good news! The exact thing you're asking for is coming in RStudio 1.3, see https://github.com/rstudio/rstudio/issues/2788 (and currently available in daily builds)

1 Like

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