On 17/12/2009 3:19 PM, Luc Villandré wrote:
Dear R-specialists,
I am trying to create a Makefile that will first convert all my .Rnw
files into .tex files and then, that will run the LaTeX compiler to
produce a pdf document. This issue has been discussed before. Hence,
I've basically adapted a Makefile I found at
http://n4.nabble.com/R-Sweave-R-and-complex-latex-projects-td810020.html#a810023
to make it compatible with a Windows XP environment. You will find my
version of it at the end of this message.
It doesn't exactly address your question, but you might also want to
look at the patchDVI package on R-forge. It takes a Rnw file as input,
runs Sweave and some version of latex, then patches the result so that
reverse search (from the .dvi or a .pdf with synctex) goes back to the
Rnw file instead of going to the .tex file.
It doesn't address the problem of an output file depending on multiple
.Rnw files, but it does at least handle the case of one .Rnw being
included by a master .tex file. For example, I use something close to
this in a batch file to process one .Rnw and display the whole thing:
echo library(patchDVI);SweaveMiktex('%2', '%3.tex') | Rterm --slave
yap -1 -s"%1%2" %3.dvi
The arguments are
%1=line number,
%2=filename of .Rnw file,
%3=basename of master file (or of the filename)
Duncan Murdoch
However, it's not doing what I expect it to do. Instead of only using
pdfTeX on "total_article.tex" (which is the file with the necessary
headers and \include's), it tries to convert all my tex files into pdf,
which of course cannot be done since only total_article.tex has the
necessary structure to be understood by the compiler.
What's wrong then with this Makefile (I am using GNU Make 3.81)?
I will be grateful for any help you can provide.
_________________________________________________
MASTER = total_article.pdf
# the master document depends on all of the tex files
Rfile = prepareScript.R
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
SWEAVE '$<'
%.pdf : %.tex
@pdflatex $<
@egrep -c $(RERUNBIB) $*.log && (bibtex $*;pdflatex $<); true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true
clean:
@del *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg \
*.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \
*.eps *.pdf
@del -f $(patsubst %.Rnw,%.tex,$(RNWFILES))
script :
Rcmd BATCH $(Rfile)
______________________________________________
R-help@r-project.org 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.