Skip to content

Instantly share code, notes, and snippets.

@Martins6
Last active October 4, 2020 00:39
Show Gist options
  • Save Martins6/14e1997da5b6c6176f908dcf2142126d to your computer and use it in GitHub Desktop.
Save Martins6/14e1997da5b6c6176f908dcf2142126d to your computer and use it in GitHub Desktop.
When you compile a document to PDF through TinyTex LaTex, you may run into errors, especially with the .Rnw files and .tex. This is a script that automatically uses TinyTex to install the missing dependencies to compile an Rnw file..
library(tidyverse)
knitr::knit2pdf('path\to\file.Rnw')
file_log <- read_file('path\to\file.log')
error_text <-
file_log %>%
stringr::str_split('\n') %>%
unlist %>%
enframe('Index', 'Text') %>%
filter(str_detect(Text, '! LaTeX')) %>%
pull(Text)
tinytex::parse_install(
text = error_text
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment