Since updating to Windows 10, I am unable to compile .rnw files with the "Compile PDF" button in Rstudio if they have citations (I use the natbib package). So, I have abandoned Sweave for Knitr. Though not as convenient as the Compile PDF button, the command
knitr::knit2pdf('my_doc.rnw')
compiles PDF's with R code, Latex, and citations without error. However, unlike the Compile PDF button, it does not automatically launch the newly-compiled PDF in Sumatra, my preferred PDF previewer. My question is, could the source code for knitr::knit2pdf, namely,
function (input, output = NULL, compiler = NULL, envir = parent.frame(),
quiet = FALSE, ...)
{
out = knit(input, output = output, envir = envir, quiet = quiet)
owd = setwd(dirname(out))
on.exit(setwd(owd))
if (is.null(compiler)) {
compiler = if (grepl("\\.rst$", out))
"rst2pdf"
else "pdflatex"
}
if (identical(compiler, "rst2pdf")) {
if (tolower(file_ext(out)) != "rst")
stop("for rst2pdf compiler input must be a .rst file")
rst2pdf(basename(out), ...)
}
else {
tinytex::latexmk(basename(out), engine = compiler, ...)
}
with_ext(out, "pdf")
}
be amended to launch and update the newly-compile PDF each time I run knitr::knit2pdf? Thanks.