Combining thesis chapters

less than 1 minute read

How to prevent building every chapter again when I combine them.


I’m pulling together the chapters of my thesis. They’ve each been written separately with knitr in different folders. I’ve been struggling to pull them all together into the SFU thesis format as each file has intro and discussion as LaTeX files. I stumbled across the solution. It is not quite working, but this is due to my including appendices and backmatter in each chapter. The solution is the package import. By adding \usepackage{import} in the preamble I can add the following:


instead of

<<ch2, child="/path/to/chapter/chapterrnwfile.Rnw", include=T, eval=T>>=


which builds the chapter again in the thesis chapter, which will be fairly time insensitive for a lot of my larger chapters. This way each chapter builds using knitr and bibtex then imports together into a final thesis document. Sometimes the simplest is the best way.

Update: So I finally pulled my thesis together and have decided import is terrible and if I use child documents and set the cache path it won’t rebuild every time.

<<ch2, child="/path/to/chapter/chapterrnwfile.Rnw", include=T, eval=T, cache.path='/path/to/chapter/cache/'>>=


also, with R3.5 things run much faster though that’s another story.