How to get "live" PDF view of markdown file? (MacOS)

Hi!

I was wondering about the different ways to preview PDFs from RStudio. I am familiar with the built-in Viewer, but this doesn't cut it for me. It reloads the entire PDF every time I knit the document, and starts from the top of the document again. In addition, it always shows the document outline in the viewer, which I don't need, and gives unnecessary clutter.

For exemplification, when I use LaTeX normally, I write in Sublime Text, and use Skim for PDF output. I have them both open in the same full screen window, and every time I compile the .tex-document, the PDF instantly updates, and is still showing the same page and location as previously. I don't have to reload the entire PDF, and I don't have to scroll down to where I was.

Is something like this possible using RStudio with a PDF output? Other external programs is also a possibility, but I haven't found any that fit.

Thanks for any and all help!

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. Not needed for this type of question.

The short answer is that there's no off-the-shelf way to do this within RStudio, without forking it and DIY. The knitr function pipes the source to pandoc to \LaTeX only when asked. It might be possible using really deep mojo to send pandoc an argument to tee the output to an external window. If it is, I suspect that it would involve either a pandoc fork, working in Haskell, or an elaborate combination of tools.

One hack that might work is to use RStudio for composition and Skim for viewing by having knitr keep tex and using Skim to render. I forget if Skim auto-reloads; if it does, that would seem to get you there if the cursor winds up in the right spot.

Thank you for the answer!

Yes, this was what I thought, then I guess I will continue to use the native solution as of now. Might look into the Skim solution in the future though, thanks for that idea!

1 Like

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