There are multiple methods for creating a bookdown. This template enables a streamlined approach where the bookdown template has been overlayed into an RStudio Project which is also a Git repository.
Bookdown is an open source R package that makes it easy to write books. It works really well within the RStudio project environment and is the preferred method within the Duke Stats department for producing and submitting honors theses.
-
Update/install: R/RStudio. This workshop assumes you have Git installed.
- Windows: install Rtools
-
Update/install tidyverse, bookdown, tinytex. Then install TinyTex distribution
install.packages(c("tidyverse", "bookdown", "tinytex"))
tinytex::install_tinytex()
- Clone your customized GitHub repository (https://github.com/DukeStatSci)
- Create a test Bookdown Book:
Build
tab >Build Book
button. Your test book should build without errors - Develop your analysis; compose and orchestrate your HTML book. Ignore PDF for now
- In bookdown, each chapter is an Rmd file found in the project root. (index.Rmd [required], 01, 02, ... 999999)
- Files and directory names that begin with underscore _ will not be processed by
bookdown::render_book()
- Cannot have identical code-chunk names
- Code chunks that produce visualizations should have a code chunk name
- Synchronize the file_name for each chapter with HEADER 1: #, line 1
- Cannot have identical identifiers for chapters and sections. Can have custom identifiers {#foo-identifier}
- Merge and Knit or Knit and Merge
- Your compiled book is in the _book directory. You may put _book and other directories into .gitignore
-
Open
index.Rmd
and Knit a single page- Note YAML metadata (title, author, bibliography, etc.)
- See LaTeX in the end of line 16
- _output.yml controls the TOC header/footer. Lines 1 & 10 identify the gitbook and PDF outputs
-
book.bib
- Copy/Paste one of the entries. Edit the identifier (i.e. the first line of the copied bib entry), the author, and the title
- Tools like Zotero can generate a .bib file
-
45-tables_are_fun.Rmd
- line 54: Reference the new citation you created in step 2
- line 61: LaTeX
$$
or$
- line 5 & 37: uncomment
library(gt)
and changeeval=TRUE
-
Build > Build Book will generate the whole gitbook and the PDF derivative
-
_bookdown.yml
: Optionally, you can edit thebook_filename
. "_main" is the default -
As time allows make a new chapter (e.g. Visualization) and display a plot without code
- Choose license(s)
- A selective list of uesthis enabled licenses can be generated automatically
Creative Commons: Attribution, Non-Commerical
https://creativecommons.org/licenses/by-nc/4.0/