从命令行更改 Sweave 驱动程序

发布于 2024-10-26 22:01:01 字数 467 浏览 6 评论 0原文

我当前用于编织的 Makefile 看起来类似于:

SUFFIXES: .tex .pdf .Rnw
MAIN = lecture
INCLUDES = chapter1.tex chapter2.tex ...

all: $(INCLUDES) $(MAIN).pdf

$(MAIN).pdf: $(INCLUDES) $(MAIN).tex

.Rnw.tex:
        R CMD Sweave $*.Rnw

.tex.pdf:
        pdflatex $*.tex


<snip>

假设我想更改 Sweave 驱动程序以使用 突出显示 包(例如)。这样做的最佳方法是什么?

My current Makefile for weaving looks something like:

SUFFIXES: .tex .pdf .Rnw
MAIN = lecture
INCLUDES = chapter1.tex chapter2.tex ...

all: $(INCLUDES) $(MAIN).pdf

$(MAIN).pdf: $(INCLUDES) $(MAIN).tex

.Rnw.tex:
        R CMD Sweave $*.Rnw

.tex.pdf:
        pdflatex $*.tex


<snip>

Suppose I want to change the Sweave driver to use the highlight package (say). What's the best way of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╭ゆ眷念 2024-11-02 22:01:01

您可以像我们对 Rcpp* 包所做的那样。这是 RcppGSL:

RcppGSL.pdf: RcppGSL/RcppGSL.Rnw
    cp -f RcppGSL/RcppGSL.Rnw .
    $(RSCRIPT) --vanilla -e "require(highlight); \
                             driver <- HighlightWeaveLatex(boxes = TRUE); \
                             Sweave( 'RcppGSL.Rnw', driver = driver ); "
    $(RSCRIPT) -e "tools::texi2dvi( 'RcppGSL.tex', pdf = TRUE, clean = FALSE )"
    bibtex RcppGSL
    $(RSCRIPT) -e "tools::texi2dvi( 'RcppGSL.tex', pdf = TRUE, clean = TRUE )"
    cp RcppGSL/RcppGSL-fake.Rnw RcppGSL.Rnw

这将实际源代码和“假”变体保留在子目录 inst/doc/RcppGSL/
仅当我们也需要时才欺骗 R 重新创建 pdf——否则它会看到具有相同基本名称的 Rnw 和 pdf 并且很高兴。

比您开始使用的基本 Makefile 稍微复杂一些,但目前仍然如此
我们知道切换到 highlight 的唯一方法。

You could do what we do for the Rcpp* packages. Here is RcppGSL:

RcppGSL.pdf: RcppGSL/RcppGSL.Rnw
    cp -f RcppGSL/RcppGSL.Rnw .
    $(RSCRIPT) --vanilla -e "require(highlight); \
                             driver <- HighlightWeaveLatex(boxes = TRUE); \
                             Sweave( 'RcppGSL.Rnw', driver = driver ); "
    $(RSCRIPT) -e "tools::texi2dvi( 'RcppGSL.tex', pdf = TRUE, clean = FALSE )"
    bibtex RcppGSL
    $(RSCRIPT) -e "tools::texi2dvi( 'RcppGSL.tex', pdf = TRUE, clean = TRUE )"
    cp RcppGSL/RcppGSL-fake.Rnw RcppGSL.Rnw

This keeps the actual source and a 'fake' variant in a subdirectory inst/doc/RcppGSL/
to trick R into recreating the pdf only when we want it too---otherwise it sees an Rnw and pdf of the same basename and is happy.

A little more convoluted than the basic Makefile you started with, but currently still
the only way to switch to highlight that we know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文