renderPdf <- function(x) {
wd <- getwd()
on.exit({
setwd(wd)
})
path <- normalizePath(dirname(x))
full_file_path <- tools::file_path_as_absolute(x)
file_wo_ext <- tools::file_path_sans_ext(basename(x))
pdf_file <- paste0(file_wo_ext, ".pdf")
# work in a temporary directory to avoid dealing with latex log files
tmp_dir <- tempdir()
setwd(tmp_dir)
tools::texi2pdf(full_file_path)
knitr:::plot_crop(pdf_file)
file.copy(pdf_file, file.path(path, pdf_file), overwrite = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.