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
Automatically install missing latex packages in Rnw vignettes #292
Comments
I don't know the exact answer for it but my understanding is that R will run
If the engine was to produce I know you can use a EDIT: in fact it is easy to find those Makefile with a github search Anyway, just sharing thoughts. @yihui may have more targeted insights for this. BTW, about this in your dockerfile
You should be able to directly install a binary of TinyTeX with the all the relevant packages by using tinytex:::install_prebuilt('TinyTeX') This is the prebuild binary with the most packages included. See https://github.com/yihui/tinytex-releases for those prebuilt binary and other installation method. This may save some installation time from |
@jeroen There are a couple of ways to solve this problem. I'm not sure which one below is dirtier :)
I've always wanted to do 3 ( The 4th possibility, which is kind of similar to 3, is to rewrite This suggestion by @cderv above is a good one:
This version of TinyTeX was (pre)built exactly for the reason of building PDF vignettes from other R packages. The file |
Actually there is the 5th possibility. That is, have an R core sponsor This will introduce a |
I have started with trying #3: set
I did confirm that tinytex is able to compile the tex file when I manually run it, so I am guessing R invokes |
Besides the env var I was wrong above: writeLines('Rscript -e "tinytex::latexmk(\'$2\', clean = FALSE)"', 'tinytex.sh')
system('chmod +x tinytex.sh')
Sys.setenv(PDFLATEX = normalizePath('tinytex.sh'))
writeLines('\\documentclass{article}\\begin{document}abc\\end{document}', 'test.tex')
tools::texi2pdf('test.tex', texi2dvi = 'emulation') |
@yihui what about passing your special program directly in
writeLines('Rscript -e "tinytex::latexmk(\'$3\')"', 'tinytex.sh')
system('chmod +x tinytex.sh')
writeLines('\\documentclass{article}\\begin{document}abc\\end{document}', 'test.tex')
tools::texi2pdf('test.tex', texi2dvi = normalizePath('tinytex.sh')) |
@cderv That might work, too. I didn't test it, but I guess it would be easier to bypass the Anyway, I just figured out why my previous attempt didn't work. I need to call |
Oh I see. It did not seem to cause issue as the document get correctly converted when I tested. I guess it would easy to write a script that understand this --help command to handle this correctly. But setting Thanks for explaining. 👍 |
OK that seems to work, even without setting |
I don't have the power to make any changes in |
@jeroen If it works fine without setting @zeileis Since we have a workaround that works okay, we don't have to ask for R core to consider the support. In fact, I'm a little worried that some of them may seriously frown upon tinytex's feature of automatically installing LaTeX packages, since this violates a CRAN policy (packages shouldn't install anything without users' permission). This is one crime that I have never confessed to CRAN, since turning off this feature by default would make the package much less useful and also waste users' time on reading the documentation (on how to turn it on). Once we rewrite the R package in another language and have a real |
OK, I understand. I have already written to Kurt and asked him (a) how CRAN generally deals with the problem of installing the required LaTeX packages and (b) whether automatically installing LaTeX packages would be a useful feature for |
To wrap this up, this solution in r-universe-org/build-source@97183f4 seems to work. A shell script #!/bin/sh
Rscript -e "tinytex::pdflatex('$2',clean = FALSE)" Put that on the PATH and then we run: R_TEXI2DVICMD=emulation PDFLATEX=pdftinytex R CMD build $PACKAGE The only drawback I found is that |
Just as a last quick follow-up after briefly talking to Kurt how CRAN deals with LaTeX packages: The Linux machines just seem to have |
I am using a docker image with tinytex to build R (source) packages on r-universe. I am looking for a way to automatically install missing latex packages used by vignettes.
Here is an example tbm_supplement.Rnw of a failing build: https://github.com/r-universe/r-forge/runs/2240700906?check_suite_focus=true
According to the tinytex manual I could use
tlmgr search --global --file "/accents.sty
however I would like an automated solution that works for all packages at once.I do not control the source code for these packages, but I can easily add hacks to my docker image that does the building, for example to override the vignette engine for Rnw files, or run some code before
R CMD build
.By filing an issue to this repo, I promise that
xfun::session_info('tinytex')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/tinytex')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: