profile
viewpoint

Ask questionsUse tinytex to compile LaTeX documents

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 https://github.com/yihui/tinytex/issues/10). Note that the rmarkdown package has already used it to compile the intermediate .tex files to PDF in rmarkdown::render(). Some tips on how the IDE options should be passed to tinytex:

image

  1. The main function to call is tinytex::latexmk().

  2. The LaTeX engine (pdflatex, xelatex, lualatex) is passed to the engine argument of latexmk().

  3. The Clean auxiliary output option is passed to the clean argument of latexmk().

  4. The Enable shell escape option is passed to latexmk(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.

rstudio/rstudio

Answer questions yihui

I just realized that #5608 only made it possible to compile .tex files via tinytex::latexmk(), but not .Rnw documents. And I was hoping the intermediate .tex from .Rnw could be compiled through tinytex as well (yihui/tinytex#10). I'm not familiar with rnw_weave::runWeave below, but it sounds like it does the two steps together ("weave" + "compile to pdf"):

https://github.com/rstudio/rstudio/blob/a675c8564ce74baf06dcc702300a21ac6484dd23/src/cpp/session/modules/tex/SessionCompilePdf.cpp#L614-L632

So somewhere inside rnw_weave::runWeave, we need to call tinytex::latexmk() if the preference use_tinytex is true.

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 .Rnw was not compiled through tinytex, so it won't work for this user (references won't be correctly resolved).

useful!

Related questions

environment pane declares S4 object as "Object with null pointer" hot 1
RStudio do not find Rtools and offer to install even if already installed hot 1
Blinking dot(s) near cursor hot 1
Sequences not supported inside backticks hot 1
Rstudio-Server: abend; LOGGED FROM: rstudio::core::Error<unnamed> hot 1
Crash when doing "Reflow Comment" hot 1
Error in file(out, "wt") : cannot open the connection hot 1
I am getting this &#34;Unable to establish connection with R session&#34; .Tried reinstalling,updating the packages but to no use. hot 1
Error creating notebook: pandoc document conversion failed with error 11 hot 1
Rstudio 1.2 crash on any rmd in windws (ERROR: option error has NULL value) hot 1
Error in tools::startDynamicHelp() : internet routines cannot be loaded hot 1
RStudio do not find Rtools and offer to install even if already installed hot 1
libxkbcommon-x11 dependency installed but not detected by the rpm + zypper hot 1
suppress 'rsession: no process found' messages when stopping RStudio Server hot 1
libclang: crash detected during parsing: hot 1
Github User Rank List