Changing the Sweave driver from the command line
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) $(MA开发者_高级运维IN).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?
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.
精彩评论