在使用.sty
在闪亮的应用程序中生成pdf报告时,我找不到本地tinytex
文件。
基本闪亮的应用程序:
shinyApp(
ui = fluidPage(
sliderInput("slider", "Slider", 1, 100, 50),
downloadButton("report", "Generate report")
),
server = function(input, output) {
output$report <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = "report.html",
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(n = input$slider)
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(tempReport, output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)
}
)
报告文件报告。Rmd:
---
title: ' '
author: ' '
output:
pdf_document:
number_sections: false
fig_caption: false
header-includes:
- \usepackage{titlepage}
fontsize:
12pt
geometry: "left = 0.6in, right = 0.6in, top = 0.8in, bottom = 0.8in"
params:
n: NA
---
```{r}
options(tinytex.verbose = TRUE)
# The `params` object is available in the document.
params$n
```
A plot of `params$n` random points.
```{r}
plot(rnorm(params$n), rnorm(params$n))
```
错误:
tlmgr search --file --global "/titlepage.sty"
Warning in parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
Failed to find a package that contains titlepage.sty
! LaTeX Error: File `titlepage.sty' not found.
! Emergency stop.
<read *>
xfun::session_info('rmarkdown')
的输出:
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134), RStudio 1.2.1335
Locale:
LC_COLLATE=Czech_Czechia.1250 LC_CTYPE=Czech_Czechia.1250 LC_MONETARY=Czech_Czechia.1250 LC_NUMERIC=C
LC_TIME=Czech_Czechia.1250
Package version:
base64enc_0.1.3 digest_0.6.19 evaluate_0.13 glue_1.3.1 graphics_3.6.0 grDevices_3.6.0 highr_0.8 htmltools_0.3.6
jsonlite_1.6 knitr_1.23 magrittr_1.5 markdown_0.9 methods_3.6.0 mime_0.6 Rcpp_1.0.1 rmarkdown_1.12
stats_3.6.0 stringi_1.4.3 stringr_1.4.0 tinytex_0.13 tools_3.6.0 utils_3.6.0 xfun_0.7 yaml_2.2.0
Pandoc version: 2.6
文件titlepage.sty
与app.R
和report.Rmd
位于同一目录中。