As part of writing a thesis it is expected that individual chapters will need to be produced without the entire thesis being put together. These would normally be passed to a student’s supervisor(s) for comment.

With that in mind the single_chapter function allows this to happen. It creates a temporary R Markdown file (that is deleted after the pdf is created) with a YAML header that includes the bibliography file provided and inserts the R Markdown file of the chosen chapter as a “child” document. For more information on child documents please see the knitr documentation.

To use the function you can copy and paste the following line into the console

or if you are using RStudio locally (rather than RStudio server) there is also an addin which allows the R Markdown file to be chosen interactively.

By default this will create a word document, if you prefer a pdf you can add the pdf = TRUE option.

To find references the function will parse the contents of index.Rmd, find the line that starts bibliography and add that line to the temporary document. This means that index.Rmd needs to be in the current working directory.