[R] Sweave Makefile issue

Gray Calhoun gray.calhoun at gmail.com
Thu Dec 17 22:13:07 CET 2009


Hi Luc,

  I haven't been actively participating in this list for that long, so
I may be wrong here... but I suspect that debugging makefiles is a bit
off topic.  Two quick points that might help: You probably want to use
"R CMD texi2dvi" on your tex files instead of pdflatex; and you'll
probably have better luck finding the dependency error in your
Makefile if you remove all of the variables (especially with
$(wildcard ...)) and create a simplistic directory structure.  Once
you get that working, you can build back up.  Using Sweave generated
LaTeX files as dependencies for other LaTeX files may be problematic
even when you get this issue sorted out (I'm not familiar enough with
Sweave to know if you can strip out the preamble, etc.)

Best,
Gray


On Thu, Dec 17, 2009 at 2:19 PM, Luc Villandré
<villandl at dms.umontreal.ca> 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.
>
> 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)
>
> --
>
> *Luc Villandré*
> /Biostatistician
> MUHC-MCH Research Institute/
>
> ______________________________________________
> R-help at 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.
>



-- 
Gray Calhoun

Assistant Professor of Economics
Iowa State University




More information about the R-help mailing list