[R] Sweave / Latex per-chapter output

Anne-Marie Ternes amternes at gmail.com
Wed Jul 2 12:05:41 CEST 2008


Hello to all who have helped me on this topic,

first I need to apologize for apparently replying only now... In fact
I use the "Pan" Newsreader to read the list, and I posted a reply to
the thread a week after your suggestions through Pan, and I only now
realised that the posting never arrived on the list although Pan gave
me no error message at all!

So, let me try again using the good old email-to-email way.

You all helped me so much! This is what I'm doing now:

- I separated my large file into several chapter files
- In each file, I include a Sweave options file using "\SweaveInput"
- I make sure to first run a "pre" file, which checks if some files
containing data from the database that I need repeatedly are there or
not, and if they are not too old. If the files are absent or expired,
the database is queried and the files recreated.
- In each file, I then "source" an init.R file, which reads the
previously created files and sets some "global" variables I'll need
all the time. So, the querying is done maximum 1 time, while the file
reading and variable setting is re-run for each chapter, which doesn't
seem to be a problem (performance-wise).
- In my master tex file, I include the different chapters. If I want
to generate PDF for only a single chapter, I cannot use the
"\includeonly" directive, because I will always need to run "pre"
first, and then the chapter I want. So, I just comment out the things
I don't want to run.
- In "my" Makefile (it's Mark's really, with some minor adaptations),
I specify the following to make sure "pre" is run first before running
the individual chapters:

RNWFILES = pre.Rnw intro.Rnw $(wildcard c*.Rnw)

So, with all this I can get "whole document" PDFs or "per-chapter" PDFs - Great!

Actually, then I go on and feed the tex file(s) to "latex2html", a
great tool, to generate HTML equivalents all ready with navigation,
buttons and all.

Maybe it's not yet perfect, but for sure it is much, much better than before!

Greetings from Luxembourg,

Anne-Marie



More information about the R-help mailing list