This R package provides a single R Markdown template and format, both named ucbthesis. This PDF document template is built on the ucbthesis LaTeX document class for PhD dissertations and Master's theses maintained and distributed by Paul Vojta. This package also builds upon/brings up-to-date features available in Steven Pollack's ucbthesis R package. This package is intended for UC Berkeley graduate students who also utilize R code in their thesis or dissertation results and/or would like to avoid setting up and editing their document using more complex markup languages (e.g. LaTeX) or word-processing software (e.g. Microsoft Word).
In short, this template requires XeLaTeX, pandoc, and the rmarkdown R package.
XeLaTeX is included with 'full' installs of TeX Live and MacTeX. To acquire pandoc and rmarkdown, you can either install the latest version of RStudio or perform manual installations:
- pandoc: instructions are provided with the rmarkdown package
- rmarkdown:
install.packages("rmarkdown")
Additionally, the sample document shipped with the ucbthesisrmd package can be rendered without modification (if you'd like to quickly see a preview of what a finished PDF could look like; see Usage below for further instructions), but the following packages must first be installed:
- pander,
- ggplot2,
- tikzDevice, and
- dagR.
install.packages(c("pander", "ggplot2", "tikzDevice", "dagR"))
To install the ucbthesisrmd R package from GitHub:
devtools::install_github("saraemoore/ucbthesisrmd")
To create a new R Markdown document using the ucbthesis template, use the rmarkdown::draft
function:
rmarkdown::draft("/path/to/my_thesis.Rmd", template = "ucbthesis", package = "ucbthesisrmd", edit = FALSE)
Alternatively, if using RStudio, begin a new document using this template by going to "File > New File > R Markdown..."
A new directory (here called 'my_thesis') will be created by default (to suppress this, add create_dir = FALSE
to the call to rmarkdown::draft()
) in the parent directory you specified (in the toy example above, /path/to/
). Within this directory, you'll find four files that you can and should modify:
- the main R Markdown document ('my_thesis.Rmd'),
- two sample chapters ('chap1.Rmd' and 'chap2.Rmd') -- also referred to below as child documents -- and
- a sample bibliography file ('references.bib').
(You'll also see a LaTeX class file, ucbthesis.cls, in this directory -- you won't need to modify this file.)
To customize this document for your thesis or dissertation, modify the YAML header in the main R Markdown document. Also in this file, add (or remove) links to child documents like chapters, an introduction, or a conclusion. Put your manuscript in the child document(s) using either (R) Markdown or TeX syntax. Your bibliographic references can go into references.bib, and further bibliography options can be set in the YAML header.
To render the document:
rmarkdown::render("/path/to/my_thesis/my_thesis.Rmd")
In RStudio, if preferred, use either the "Knit" button or the keyboard shortcut (Ctrl+Shift+K).
Note: If you run the above command within the R console and get a xelatex: command not found
error, try running R from the shell.
See the wiki for advanced usage of this package.