[R] Sweave / Latex per-chapter output

Jean lobry lobry at biomserv.univ-lyon1.fr
Wed May 21 17:29:32 CEST 2008


Dear Anne-Marie,

we had a similar problem to handle the LaTeX book that ships with the
seqinr package (http://pbil.univ-lyon1.fr/software/seqinr/seqinr_1_1-5.pdf).

Here is basically the approach we have used:

o Each book chapter is written first as a LaTeX article produced by Sweaving
   its corresponding *.rnw file. They are therefore available as individual
   articles in PDF.

o The book itself is produced by collating the core of each LaTeX source
   files and turning articles titles into chapter titles (among other things
   such as computing the full author list from article authors). The book is
   therefore also available in PDF without changing the *.rnw files.

There are of course some constraints for this to work (e.g. all articles
are sharing the same *.bib file, all figures are in the same folder and
we are using the following (ugly) construct:

<<hack, echo=FALSE, fig=FALSE, results=hide, eval=TRUE>>=
.CurFileName <- get("file", env = parent.frame(3))
.PrefixName <- strsplit(.CurFileName, "\\.")[[1]][1]
@

\SweaveOpts{prefix.string = ../figs/\Sexpr{.PrefixName} }

to avoid collisions between figures names produced by Sweave by prefixing
them with the current *.rnw file name, etc.)

If you want to know more the source code for the book is distributed with
the seqinr package in the /doc/src folder, see /doc/src/template/template.pdf
file as a starter. Please send an e-mail to the seqinr diffusion list if you
have more questions.

HTH,

Jean

-- 
Jean R. Lobry            (lobry at biomserv.univ-lyon1.fr)
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
allo  : +33 472 43 27 56     fax    : +33 472 43 13 88
http://pbil.univ-lyon1.fr/members/lobry/



More information about the R-help mailing list