Skip to content

Instantly share code, notes, and snippets.

@cboettig
Created January 10, 2012 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cboettig/1591001 to your computer and use it in GitHub Desktop.
Save cboettig/1591001 to your computer and use it in GitHub Desktop.
knitr makefile (updated)
## Makefile to use knitr in the vignette
all: knit
setvars:
ifeq (${R_HOME},)
R_HOME= $(shell R RHOME)
endif
RPROG= $(R_HOME)/bin/R
RSCRIPT=$(R_HOME)/bin/Rscript
pdfclean:
rm -f *.pdf
clean:
rm -f index.html
rm -f *.tex *.bbl *.blg *.aux *.out *.log *.spl *tikzDictionary
# Custom command for my local compile
knit:
$(RSCRIPT) --vanilla -e ".libPaths(c('~/R', .libPaths())); require(knitr); knit( 'knit_treebase.Rnw', 'treebase.Rnw');"
$(RPROG) CMD Sweave treebase.Rnw
pdflatex treebase
bibtool -s -d -x treebase.aux ~/Documents/Mendeley/bib/library.bib > treebase.bib
bibtex treebase # make the bibliography
pdflatex treebase
pdflatex treebase
rm -f *.bbl *blg *.aux *.out *.log *.spl
cp -f treebase.Rnw treebase.tex treebase.bib *.pdf ..
## Traditional compile
treebase.pdf: treebase.Rnw
$(RPROG) CMD Sweave treebase.Rnw
$(RSCRIPT) -e "tools::texi2dvi( 'treebase.tex', pdf = TRUE, clean = FALSE )"
bibtex treebase # make the bibliography
$(RSCRIPT) -e "tools::texi2dvi( 'treebase.tex', pdf = TRUE, clean = TRUE )" # compile and cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment