[R] Sweave, R and complex latex projects
Mark Wardle
mark at wardle.org
Thu Nov 9 21:02:41 CET 2006
All,
This is an update to my previous query on dealing with complex (complex
in my eyes anyway) LaTeX/Sweave projects. Based on the work of others,
please see my current thesis Makefile below. I didn't get Sweave and
LaTeX to cope with a master document in one directory, and chapters in
subdirectories, so instead I moved all individual chapter .tex and .Rnw
files into the same directory. The only reason for having directories in
the first place was to group all the charts and tables etc. and Sweave
makes that unnecessary anyway.
The other issue is that Sweave can interact with typeface settings in a
LaTeX document. One may avoid this by using the [noae] option, or just
making sure any typeface directives (including \usepackage{times}) come
after the \usepackage{Sweave} directive in your master LaTeX document.
I hope this is of help to someone else... No guarantees as I am not a
Makefile expert!
#
# Makefile
#
#
# Global project Makefile
#
#
# This makefile was based on
#
http://209.85.135.104/search?q=cache:-fU4UEn36AgJ:kriemhild.uft.uni-bremen.de/viewcvs/Makefile.rnoweb+makefile+sweave+latex&hl=en&ct=clnk&cd=10&client=safari
# (The original file found on Google is no longer available and I
couldn't track a new version)
# This is credited to Johannes Ranke, based on work by Nicholas
Lewin-Koh and Rouben Rostmaian, and also from Deepayan Sarkar's email on
the R-help mailing list.
#
# The master document (document preamble, \include's the other files) is
thesis.tex
MASTER = thesis.pdf
# the master document depends on all of the tex files
RNWFILES = $(wildcard *.Rnw)
TEXFILES = $(wildcard *.tex)
DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES)
RERUN = "(There were undefined references|Rerun to get
(citations|cross-references|the bars) (correct|right)|Table widths have
changed. Rerun LaTeX.|Linenumber reference failed)"
RERUNBIB = "No file.*\.bbl|Citation.*undefined"
all: $(MASTER)
$(MASTER): $(DEPENDS)
%.tex: %.Rnw
R CMD SWEAVE '$<'
%.pdf: %.tex
@pdflatex $<
@egrep -c $(RERUNBIB) $*.log && (bibtex $*;pdflatex $<); true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true
clean:
@rm -f *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg \
*.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \
*.eps *.pdf
@rm -f $(patsubst %.Rnw,%.tex,$(RNWFILES))
--
Dr. Mark Wardle
Clinical research fellow and Specialist Registrar in Neurology,
C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK
More information about the R-help
mailing list