繁体   English   中英

knit2pdf():编织和乳胶通过

[英]knit2pdf(): knit and latex passes

我正在使用knit2pdf("book.Rnw", quiet=TRUE)在RStudio下编译书籍项目。 编织步骤需要很长时间(我还没有使用缓存),并且当有新的引用,图形,交叉引用等时,即使.Rnw文件没有更改,也需要花费几步来解决它们。

我想要的是knit2pdf的等效项或扩展名,它允许knit=FALSE禁止重新生成.tex文件,或者允许选择latex.passes=请求其他tools::texi2pdf运行tools::texi2pdf

我看了knit2pdf中的代码,它有点不透明,无法为该功能提供简单的补丁。

knit2pdf所做的所有工作都是生成一个.tex文件,然后调用tools:texi2pdf 如果您正在寻找的knit2pdf版本不会首先生成.tex文件,那么它就是tools::texi2pdf

使用stringr::str_replace ,我做了类似的事情,发现已经足够了:

knit2pdf_mod <- function(rnw_file) {
    knit2pdf(rnw_file, compiler = "xelatex")
    texi2pdf(file = str_replace(rnw_file, pattern = "Rnw", replacement = "tex"))
}

您可以抛出一个for循环来重复texi2pdf步骤。

knit2pdf_mod <- function(rnw_file, latex.passes = 1) {
    knit2pdf(rnw_file, compiler = "xelatex")
    for (i in 1:latex.passes) {
        texi2pdf(file = str_replace(rnw_file, pattern = "Rnw", replacement = "tex"))
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM