Issue
When attempting to generate PDFs from R Markdown documents in Posit Connect, you may encounter LaTeX compilation errors similar to:
LaTeX failed to compile [...].tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
Description
This error typically occurs because TinyTeX is installed on a per-user basis by default, and the service user that Connect creates to run applications does not have a home directory into which TinyTeX can be installed. In combination with Connect sand boxing deployed applications for security, TinyTex will not install without administrator intervention.
Solution
Posit's recommended best practice for PDF generation in Connect is to use Quarto with Typst instead of TinyTeX/LaTeX. This approach offers several advantages:
- Typst is a modern markup-based typesetting system that creates beautiful PDF output with fast render times
- It's easier to learn and use compared to LaTeX
- Installation and configuration in Connect is straightforward
- The setup is more robust and migrates easily
To implement this solution:
- Install Quarto on your Connect server
- Configure Connect to use Quarto
- Update your R Markdown documents to use the Quarto format
If you must use LaTeX/TinyTeX, you'll need to ensure the Applications.RunAs user (default: rstudio-connect) has access to the TinyTeX executables and installation directory. Review the TinyTeX FAQ (questions 5-8) for implementation options within your environment.
For more information about Quarto and Typst, see:
If you're still having issues, you can reach out to Support by opening a ticket here.