New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use tinytex to compile LaTeX documents #2788
Comments
|
@jmcphers this would be nice to get in for RStudio v1.2; do you think we have the time to squeeze it in? |
|
It'd certainly be nice! I've added it optimistically to the backlog for 1.2 but we should prioritize some of the longer-standing bugs/regressions over this. |
|
Just wanted to chime in here that using tinytex to compile PDF would be really nice! |
|
I believe this has become somewhat higher priority for v1.3. Newer versions of MiKTeX hide the "full" installer somewhat, and only provide the basic installer; at least based on what I see from https://miktex.org/download. This implies that attempts to compile PDFs will fail by default, even with MiKTeX installed. Normally, MiKTeX will try to prompt you to install missing packages, but we've seen that fail (and of course that will fail if you lack internet connectivity) It's possible to request a "full" installation if you use the "net" installer (which is not the most prominently visible installer), and then request a "full" install in that wizard. But that's definitely not the path most users will take. |
|
#5490 provided a way to install TinyTeX, which is great! What I requested in this issue was actually to use |
|
This is currently only available in the daily builds of RStudio. |
|
I see... Thank you! |
|
I just realized that #5608 only made it possible to compile .tex files via rstudio/src/cpp/session/modules/tex/SessionCompilePdf.cpp Lines 614 to 632 in a675c85
So somewhere inside I was just about to tell the user who asked the question https://stackoverflow.com/q/61029677/559676 to try the daily build, but after I tested it, I realized |
|
It looks like we normally run R as a sub-process when weaving And this is where that all happens: rstudio/src/cpp/session/modules/tex/SessionRnwWeave.cpp Lines 509 to 572 in d24a955
@yihui, can you share what the right way to invoke |
|
@kevinushey In your case, I think you were using Sweave: If you change Sweave to knitr, you will probably see Anyway, Please let me know if you need further explanation. Thanks! |
|
@yihui sorry for taking so long to respond. You are correct that I was using Sweave; sorry for missing that part. This is where we're building the command to invoke rstudio/src/cpp/session/modules/tex/SessionRnwWeave.cpp Lines 265 to 281 in fafd617
And this is where we run the latex compiler after a successful weave (or knit): rstudio/src/cpp/session/modules/tex/SessionCompilePdf.cpp Lines 730 to 804 in fafd617
So I think we need to use |
|
Fixed via #8570 -- this should ensure that the |
|
Awesome! Thanks @kevinushey! |
|
Here is an \documentclass{article}
\begin{document}
<<>>=
# tinytex should automatically reinstall this package later
tinytex::tlmgr_remove('framed')
# test bibliography
knitr::write_bib('base', 'test.bib')
@
\cite{R-base}
\bibliography{test.bib}
\bibliographystyle{unsrt}
\end{document}If this feature is implemented correctly and you have TinyTeX installed ( 1) The log2) The PDF output |
|
Verified in
Tested using sample code from http://mally.stanford.edu/~sr/computing/latex-example.html and https://www.overleaf.com/latex/examples/dodecahedron-desk-calendar/mrjbknbbrjhy |
|
Can also confirm the example in #2788 (comment) works as expected. |



I think the tinytex package is mature enough now (it has been on CRAN for about half a year), so we may consider using it to compile LaTeX documents (including Rnw documents rstudio/tinytex#10). Note that the rmarkdown package has already used it to compile the intermediate
.texfiles to PDF inrmarkdown::render(). Some tips on how the IDE options should be passed to tinytex:The main function to call is
tinytex::latexmk().The LaTeX engine (
pdflatex,xelatex,lualatex) is passed to theengineargument oflatexmk().The
Clean auxiliary outputoption is passed to thecleanargument oflatexmk().The
Enable shell escapeoption is passed tolatexmk(engine_args = '-shell-escape').The main advantages of using tinytex is that it will process bibliographies and resolve other cross-references correctly (compile the .tex for a correct number of times). If the user has installed TinyTeX (
tinytex::install_tinytex()), missing LaTeX packages can also be installed automatically.Let me know if you need any other information.
The text was updated successfully, but these errors were encountered: