I have an R Markdown document that by default knits to PDF. When I click on knit, it runs and opens a preview of the document. It doesn't save the PDF in the source directory.
When I ask to print from the main RStudio File menu, the source for the document is printed instead of the output. I don't see a way in the preview window to ask to print the document. Am I missing something, or is this a bug in the Print command?
I'm using RStudio version 2025.09.2+418 (2025.09.2+418) on MacOS Sequoia 15.7.2.
By the way, a workaround for this is to run rmarkdown::render(<srcfile>) in the R console. This does produce a PDF in the current directory. Clicking on it opens it in the MacOS Preview app, which can print it.
If you click the "Knit options" button (small downward arrow next to "Knit") and then click "Knit Directory", to what is it set (and do you find the PDF there after knitting)? On my system (Linux Mint) it defaults to "Document Directory", and the PDF file does indeed land there.
It is set to "Document Directory". But it's not ~/Documents .
If I look at the Pandoc output, it says the file was put in /private/var/folders/0d/lm5nf_791193x0hxv5gvw5s40000gn/T/RtmplFfRmP/preview-164d676804cc9.dir/filename.pdf, which is under the R temp directory tempdir(). Checking with list.files() does show it there.
I've also found the answer to my question: yes, I missed something. If the preview window is big enough, there's a little printer icon which does cause the output to print. If it's a little smaller (the default size on my laptop), then that icon moves to a dropdown list you get by clicking on the >> icon on the top right of the window.