djmurphy420/ggplot2-transition-guide — comment on commit ae050eb3133ce559adc1488edb96231fb2b08081
File: ggplot2-0.9.0-BW.Rnw line 1353
By yihui:

I should have emailed you earlier, since I thought you would do this: make two copies of the same document. This is not the optimal way. Ideally you should only maintain one copy of the source document and compile it with different options. In this case, you can use two directories to put colored and BW output respectively, e.g. your dir structure is like this:

```
./guide.Rnw
-- colored/
-- bw/
```

then you can go to each directory and call knitr with different options:

```r
library(ggplot2)
library(knitr)

setwd('./colored/')
theme_set(theme_gray()) # set gray theme
opts_chunk$set(highlight = TRUE) # turn on highlighting
knit2pdf('../guide.Rnw', 'guide-colored.tex')

setwd('../bw/')
theme_set(theme_bw()) # set BW theme
opts_chunk$set(highlight = FALSE) # turn on highlighting
knit2pdf('../guide.Rnw', 'guide-bw.tex')
```

I'm almost sure it will be hell to maintain two source documents in the future :)