[R] Sweave / Latex per-chapter output

Brett Presnell presnell at stat.ufl.edu
Wed May 21 14:05:20 CEST 2008


"Anne-Marie Ternes" <amternes at gmail.com> writes:

> What I would like to do, is to be able to get 2 types of output with
> the same code (I'm lazy ;-) ):
> ...
> 2. a PDF and HTML file *per chapter*, for displaying on our website
> and allowing people to download individual chapters
> 
> ...
> 
> BTW, I'm working on Ubuntu Linux.

I'm assuming that you are using pdflatex to process the latex file(s)
produced by Sweave.

Assuming also that you are using latex's \include command (e.g.,
\include{chap1}, \include{chap2}, etc.) inside your master file, you
could add a line like

\includeonly{chap2}

in the preamble to just create a pdf file containing only Chapter 2.
The easiest way to do this is probably to edit the master latex file
by hand, after having run pdflatex a few times to produce the full
document (you need to do this to get all the pagination and
cross-referencing information into the .aux, .toc, and other files).

Another way to accomplish 2 is to install Ubuntu's pdftk package then
use the pdftk command with the "cat" option to extract whatever pages
you want.



More information about the R-help mailing list