从命令行更改Sweave驱动程序

csg*_*pie 5 latex r sweave

我目前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>
Run Code Online (Sandbox Code Playgroud)

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

Dir*_*tel 6

你可以做我们为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
Run Code Online (Sandbox Code Playgroud)

这使得实际的源和"假"变体的子目录inst/doc/RcppGSL/ 至R诱骗重建只有当我们希望它太PDF -否则它看到一个RNW和相同基的PDF和幸福.

Makefile你开始时的基本更复杂,但目前仍然是切换到突出我们所知道的唯一方法.