Latex failed to compile Markdown PDF from R shiny

1.1k views Asked by At

Sorry if I'm missing some information here. I'm trying to render a PDF from R shiny and R Markdown, but keep getting this error. The whole thing does run in HTML, but the idea is that I can export a PDF.

I've tried reinstalling tinytex, installing MikTex, using non-temporary setup in Shiny, and using options(tinytex.verbose = TRUE) in the code, but it doesn't give any clue where the problem is.


"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Consultants_normal.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandoc7ea82ffe49d2.tex --lua-filter "C:\Users\xxx\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\xxx\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in" 
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/W32TeX) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
Warning: Error in : LaTeX failed to compile C:\Users\xxx\AppData\Local\Temp\RtmpqUZDpX\file7ea82b6d767c.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips.
  [No stack trace available]

This is my R Shiny output for the Markdown doc:

output$ConsultantsReport <- downloadHandler(
            # For PDF output, change this to "report.pdf"
            filename = "report.pdf",
            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(), "Consultants_normal.Rmd")
                file.copy("Consultants_normal.Rmd", tempReport, overwrite = TRUE)
                
                # Set up parameters to pass to Rmd document
                params <- list(DateRange1 = input$dateRange[1],
                               DateRange2 = input$dateRange[2],
                               ConsultantName = input$SelectedConsultantName,
                               Data = MergedPaymentInfo())
                
                # 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())
                )
            }
        )

And this is the JML in R Markdown:

---
title: "Consultants Statement Normal"
author: "xxx"
params:
  DateRange1: NA,
  DateRange2: NA,
  ConsultantName: NA,
  Data: NA
output: pdf_document
---
0

There are 0 answers