Hi everybody!
Is it possible that shinyapps.io does not support any other Latex rendering engines than pdfLatex?
For a Shiny app that renders rmarkdown documents with unicode characters, I want to use the xelatex or the lualatex latex engine. As soon as I define one of these engines in the YAML header of the rmarkdown file, the rendering of the rmarkdown file crashes when triggered in a Shiny app running on shinyapps (it works locally as well as on RStudio Connect).
So I create two rmarkdown files, one with pdflatex (default) and one with lualatex latex rendering engine:
lualatex.Rmd:
---
output:
pdf_document:
latex_engine: lualatex
---
Hello! This is lualatex.
pdflatex.Rmd:
---
output:
pdf_document:
latex_engine: pdflatex
---
Hello! This is pdflatex.
Then I create a super-simple Shiny app with two download buttons, both triggering rmarkdown::render()
- once for the pdflatex, and once for the lualatex rmarkdown file:
app.R:
library(shiny)
ui <- fluidPage(
downloadButton("button_pdflatex", label = "Pdflatex"),
downloadButton("button_lualatex", label = "Lualatex")
)
server <- function(input, output) {
# Pdflatex engine
output$button_pdflatex <- downloadHandler(
filename = function() {
"pdflatex.pdf"
},
content = function(con) {
rmarkdown::render("pdflatex.Rmd",
output_file = con,
envir = new.env())
}
)
# Lualatex engine
output$button_lualatex <- downloadHandler(
filename = function() {
"lualatex.pdf"
},
content = function(con) {
rmarkdown::render("lualatex.Rmd",
output_file = con,
envir = new.env())
}
)
}
shinyApp(ui = ui, server = server)
When I run this app locally, it works perfectly clicking both buttons. When I deploy it on our Company's RStudio Connect server, also works perfectly.
When I try to deploy it to shinyapps, the pdflatex works, but the lualatex fails with the following error message (out of the shinyapps logs):
2020-03-27T15:56:55.427658+00:00 shinyapps[1998917]: processing file: lualatex.Rmd
2020-03-27T15:56:55.428687+00:00 shinyapps[1998917]: ordinary text without R code
2020-03-27T15:56:55.428687+00:00 shinyapps[1998917]:
2020-03-27T15:56:55.428784+00:00 shinyapps[1998917]:
2020-03-27T15:56:55.429249+00:00 shinyapps[1998917]: output file: lualatex.knit.md
2020-03-27T15:56:55.429250+00:00 shinyapps[1998917]:
2020-03-27T15:56:55.430641+00:00 shinyapps[1998917]: /opt/connect/ext/pandoc2/pandoc +RTS -K512m -RTS lualatex.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output /tmp/RtmpsdeVi1/file183a17fb39.tex --self-contained --highlight-style tango --pdf-engine lualatex --variable graphics --lua-filter /opt/R/3.6.3/lib/R/library/rmarkdown/rmd/lua/pagebreak.lua --lua-filter /opt/R/3.6.3/lib/R/library/rmarkdown/rmd/lua/latex-div.lua --variable 'geometry:margin=1in'
2020-03-27T15:56:56.320490+00:00 shinyapps[1998917]: cannot setup TLPDB in /home/shiny/texmf at /usr/bin/tlmgr line 5604.
2020-03-27T15:56:56.323812+00:00 shinyapps[1998917]: Warnung in system2("tlmgr", args, ...)
2020-03-27T15:56:56.323814+00:00 shinyapps[1998917]: Ausführung von Kommando ''tlmgr' search --file --global '/unicode-math.sty'' ergab Status 2
2020-03-27T15:56:56.325065+00:00 shinyapps[1998917]: ! LaTeX Error: File `unicode-math.sty' not found.
2020-03-27T15:56:56.325067+00:00 shinyapps[1998917]:
2020-03-27T15:56:56.325067+00:00 shinyapps[1998917]: ! Emergency stop.
2020-03-27T15:56:56.325068+00:00 shinyapps[1998917]: <read *>
2020-03-27T15:56:56.327356+00:00 shinyapps[1998917]: Warnung: Error in : LaTeX failed to compile /tmp/RtmpsdeVi1/file183a17fb39.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See file183a17fb39.log for more info.
2020-03-27T15:56:56.325069+00:00 shinyapps[1998917]:
2020-03-27T15:56:56.332635+00:00 shinyapps[1998917]: [No stack trace available]
Trying it with xelatex, a similar error appears. I don't understand that error message - how could I somehow incorporate unicode-math.sty
. Thank you so much for your help!