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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With