0

Update: After hours worth of trying stuff, I figured it out from this thread. Basically, I just had to detach the package KableExtra in between each call to render(), and all of the PDFs rendered in RConsole.

I have a series of R markdown documents that render in RStudio by clicking on the "Knit" button. I'm trying to write a script that will render all of the documents at once instead of waiting to click the button after each one renders, but when I run it in the Console, I keep getting errors.

Calls to render are as follows: render(input="path/markdown_file.Rmd",output_format="pdf_document")

Here's what I know:

  • Both RStudio and R Console are running R version 4.2.2
  • Both are using pandoc version 2.19.2
  • Both have current versions of the rmarkdown package
  • Both are using pdflatex to render the PDFs
  • Both are rendering HTML files using html_document with no issues

The error message I'm getting in RConsole is: `! Undefined control sequence. ...r}[t]{llrrrrrrrrrrrrrrrrl} \toprule \textbf {metric} & \textbf... l.693 \end{tabular}}

Error: LaTeX failed to compile markdown_file.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See markdown_file.log for more info.`

The only difference I'm seeing is a slight difference in the calls to pandoc:

`"C:/Program Files/RStudio/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS markdown_file.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output markdown_file.tex --lua-filter "C:\Users\XXXXXXX\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\XXXXXXX\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\latex-div.lua" --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics *--include-in-header "C:\Users\XXXXXXX\AppData\Local\Temp\RtmpoJICVK\rmarkdown-str196079161973.html"*`

The Knit button in RStudio has the last part in italics, but the R Console does not. It's some reference to a temp file, but it gets deleted immediately so I can't see what's in it.

Any ideas on how to fix this?

bentwells
  • 1
  • 2
  • Do both systems have the same version of tinytex? – Reeza Jan 04 '23 at 22:47
  • Sorry, but this makes no sense. Why are you doing this? Put your documents as vignettes in a package. Don't try to reproduce what packages do. Packages aren't just for CRAN, they're a useful way to organize R code and documentation. – user2554330 Jan 04 '23 at 22:49

0 Answers0