Re: [R] Sweave, R and complex latex projects

From: Mark Wardle <mark_at_wardle.org>
Date: Thu 09 Nov 2006 - 20:02:41 GMT

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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri Nov 10 11:25:49 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 10 Nov 2006 - 02:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.