From 38b82daff5961859dda0e332af336135ce87f81c Mon Sep 17 00:00:00 2001 From: Chester Ismay Date: Mon, 27 Jan 2020 13:06:10 -0800 Subject: [PATCH 01/20] Tweak phrasing --- inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd index b137c885..20cf7b2e 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd @@ -44,7 +44,7 @@ lof: true -Do not include 00(two-hyphens)prelim.Rmd and 00-abstract.Rmd in the YAML file--they are handled in the YAML above differently for the PDF version. + - # Introduction {.unnumbered} @@ -83,7 +124,8 @@ Welcome to the _R Markdown_ thesis template. This template is based on (and in m Hopefully, you won't have much of a learning period to go through and you will reap the benefits of a nicely formatted thesis. The use of LaTeX in combination with _Markdown_ is more consistent than the output of a word processor, much less prone to corruption or crashing, and the resulting file is smaller than a Word file. While you may have never had problems using Word in the past, your thesis is likely going to be about twice as large and complex as anything you've written before, taxing Word's capabilities. After working with _Markdown_ and **R** together for a few weeks, we are confident this will be your reporting style of choice going forward. **Why use it?** @@ -91,7 +133,8 @@ If you're still on the fence about using _R Markdown_, check out the resource fo _R Markdown_ creates a simple and straightforward way to interface with the beauty of LaTeX. Packages have been written in **R** to work directly with LaTeX to produce nicely formatting tables and paragraphs. In addition to creating a user friendly interface to LaTeX, _R Markdown_ also allows you to read in your data, to analyze it and to visualize it using **R** functions, and also to provide the documentation and commentary on the results of your project. Further, it allows for **R** results to be passed inline to the commentary of your results. You'll see more on this later. **Who should use it?** @@ -99,4 +142,5 @@ Having your code and commentary all together in one place has a plethora of bene Anyone who needs to use data analysis, math, tables, a lot of figures, complex cross-references, or who just cares about the final appearance of their document should use _R Markdown_. Of particular use should be anyone in the sciences, but the user-friendly nature of _Markdown_ and its ability to keep track of and easily include figures, automatically generate a table of contents, index, references, table of figures, etc. should make it of great benefit to nearly anyone writing a thesis project. **For additional help with bookdown** + Please visit [the free online bookdown reference guide](https://bookdown.org/yihui/bookdown/). From 46dce4572fe027f51e1335cab4348d2492e61265 Mon Sep 17 00:00:00 2001 From: Chester Ismay Date: Mon, 25 May 2020 16:27:44 -0700 Subject: [PATCH 06/20] Move preliminary content to their own folder --- .../thesis/skeleton/prelims/00--prelim.Rmd | 16 ++++++++++++++++ .../thesis/skeleton/prelims/00-abstract.Rmd | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 inst/rmarkdown/templates/thesis/skeleton/prelims/00--prelim.Rmd create mode 100644 inst/rmarkdown/templates/thesis/skeleton/prelims/00-abstract.Rmd diff --git a/inst/rmarkdown/templates/thesis/skeleton/prelims/00--prelim.Rmd b/inst/rmarkdown/templates/thesis/skeleton/prelims/00--prelim.Rmd new file mode 100644 index 00000000..369af4f9 --- /dev/null +++ b/inst/rmarkdown/templates/thesis/skeleton/prelims/00--prelim.Rmd @@ -0,0 +1,16 @@ +# Preliminary Content {-} + +## Acknowledgements {-} + +I want to thank a few people. + +## Preface {-} + +This is an example of a thesis setup to use the reed thesis document class +(for LaTeX) and the R bookdown package, in general. + +## Dedication {-} + +You can have a dedication here if you wish. + +`r if(!knitr:::is_latex_output()) '## Abstract {-}'` diff --git a/inst/rmarkdown/templates/thesis/skeleton/prelims/00-abstract.Rmd b/inst/rmarkdown/templates/thesis/skeleton/prelims/00-abstract.Rmd new file mode 100644 index 00000000..5aaf6a75 --- /dev/null +++ b/inst/rmarkdown/templates/thesis/skeleton/prelims/00-abstract.Rmd @@ -0,0 +1,3 @@ +The preface pretty much says it all. \par + +Second paragraph of abstract starts here. From 0171f75a5a2310e7cc2c2037e46ea72da13157d4 Mon Sep 17 00:00:00 2001 From: Chester Ismay Date: Mon, 25 May 2020 16:28:50 -0700 Subject: [PATCH 07/20] Start using {here} --- DESCRIPTION | 7 ++++--- inst/rmarkdown/templates/thesis/skeleton/.here | 0 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 inst/rmarkdown/templates/thesis/skeleton/.here diff --git a/DESCRIPTION b/DESCRIPTION index 14405620..828ab11a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: thesisdown Title: An updated R Markdown thesis template using the bookdown package -Version: 0.0.3 +Version: 0.1.0 Authors@R: c( person("Chester", "Ismay", email = "chester.ismay@gmail.com", role = "cre"), person("Nick", "Solomon", email = "nick@nicksolomon.me", role = "aut")) @@ -15,9 +15,10 @@ Depends: dplyr, ggplot2, bookdown, - knitr + knitr, + here License: MIT Encoding: UTF-8 LazyData: true SystemRequirements: pandoc (>= 1.18) - http://pandoc.org -RoxygenNote: 7.0.2 +RoxygenNote: 7.1.0 diff --git a/inst/rmarkdown/templates/thesis/skeleton/.here b/inst/rmarkdown/templates/thesis/skeleton/.here new file mode 100644 index 00000000..e69de29b From c719ce4256e63a752c8e05dcea78bd5cd05c574a Mon Sep 17 00:00:00 2001 From: Chester Ismay Date: Mon, 25 May 2020 16:33:22 -0700 Subject: [PATCH 08/20] Apply {styler} / Can't use rmd_files with {thesisdown} in _bookdown.yml --- R/thesis.R | 70 ++++++++++-------- R/thesisdown.R | 2 +- .../templates/thesis/skeleton/00--prelim.Rmd | 16 ---- .../templates/thesis/skeleton/00-abstract.Rmd | 3 - .../templates/thesis/skeleton/01-chap1.Rmd | 39 ++++++---- .../templates/thesis/skeleton/03-chap3.Rmd | 74 ++++++++++++++++--- .../templates/thesis/skeleton/05-appendix.Rmd | 6 +- .../templates/thesis/skeleton/_bookdown.yml | 7 +- .../templates/thesis/skeleton/skeleton.Rmd | 8 +- 9 files changed, 136 insertions(+), 89 deletions(-) delete mode 100644 inst/rmarkdown/templates/thesis/skeleton/00--prelim.Rmd delete mode 100644 inst/rmarkdown/templates/thesis/skeleton/00-abstract.Rmd diff --git a/R/thesis.R b/R/thesis.R index 89111c05..86b0c44c 100644 --- a/R/thesis.R +++ b/R/thesis.R @@ -5,37 +5,40 @@ #' #' @export #' -#' @param toc A Boolean (TRUE or FALSE) specifying whether table of contents should be created +#' @param toc A Boolean (TRUE or FALSE) specifying whether table of contents +#' should be created #' @param toc_depth A positive integer #' @param ... Further arguments passed to or from other methods. -#' @param highlight Syntax highlighting style. Supported styles include "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass NULL to prevent syntax highlighting. +#' @param highlight Syntax highlighting style. Supported styles include +#' "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", +#' and "haddock". Pass NULL to prevent syntax highlighting. #' #' @return A modified \code{pdf_document} based on the Reed Senior Thesis LaTeX #' template #' @examples #' \dontrun{ -#' output: thesisdown::thesis_pdf +#' output:thesisdown::thesis_pdf #' } -thesis_pdf <- function(toc = TRUE, toc_depth = 3, highlight = "default", ...){ - - base <- bookdown::pdf_book(template = "template.tex", +thesis_pdf <- function(toc = TRUE, toc_depth = 3, highlight = "default", ...) { + base <- bookdown::pdf_book( + template = "template.tex", toc = toc, toc_depth = toc_depth, highlight = highlight, keep_tex = TRUE, pandoc_args = "--top-level-division=chapter", - ...) + ... + ) # Mostly copied from knitr::render_sweave base$knitr$opts_chunk$comment <- NA - #base$knitr$opts_chunk$fig.align <- "center" + # base$knitr$opts_chunk$fig.align <- "center" old_opt <- getOption("bookdown.post.latex") options(bookdown.post.latex = fix_envs) on.exit(options(bookdown.post.late = old_opt)) base - } #' Creates an R Markdown gitbook Thesis document @@ -49,14 +52,19 @@ thesis_pdf <- function(toc = TRUE, toc_depth = 3, highlight = "default", ...){ #' @return A gitbook webpage #' @examples #' \dontrun{ -#' output: thesisdown::thesis_gitbook +#' output:thesisdown::thesis_gitbook #' } -thesis_gitbook <- function(...){ - +thesis_gitbook <- function(...) { config_default <- list( - toc = list(collapse = "section", - before = '
  • ', - after = '
  • Published with bookdown
  • ')) + toc = list( + collapse = "section", + before = '
  • ', + after = paste( + '
  • Published with bookdown
  • ' + ) + ) + ) listarg <- list(...) @@ -89,7 +97,6 @@ thesis_gitbook <- function(...){ base$knitr$opts_chunk$fig.align <- "center" base - } #' Creates an R Markdown Word Thesis document @@ -104,10 +111,9 @@ thesis_gitbook <- function(...){ #' the Reed Senior Thesis Word template #' @examples #' \dontrun{ -#' output: thesisdown::thesis_word +#' output:thesisdown::thesis_word #' } -thesis_word <- function(...){ - +thesis_word <- function(...) { base <- bookdown::word_document2(...) # Mostly copied from knitr::render_sweave @@ -115,7 +121,6 @@ thesis_word <- function(...){ base$knitr$opts_chunk$fig.align <- "center" base - } #' Creates an R Markdown epub Thesis document @@ -129,10 +134,9 @@ thesis_word <- function(...){ #' @return A ebook version of the thesis #' @examples #' \dontrun{ -#' output: thesisdown::thesis_epub +#' output:thesisdown::thesis_epub #' } -thesis_epub <- function(...){ - +thesis_epub <- function(...) { base <- bookdown::epub_book(...) # Mostly copied from knitr::render_sweave @@ -140,17 +144,21 @@ thesis_epub <- function(...){ base$knitr$opts_chunk$fig.align <- "center" base - } -fix_envs = function(x){ - beg_reg <- '^\\s*\\\\begin\\{.*\\}' - end_reg <- '^\\s*\\\\end\\{.*\\}' - i3 = if (length(i1 <- grep(beg_reg, x))) (i1 - 1)[grepl("^\\s*$", x[i1 - 1])] +fix_envs <- function(x) { + beg_reg <- "^\\s*\\\\begin\\{.*\\}" + end_reg <- "^\\s*\\\\end\\{.*\\}" + i3 <- if (length(i1 <- grep(beg_reg, x))) { + (i1 - 1)[grepl("^\\s*$", x[i1 - 1])] + } - i3 = c(i3, - if (length(i2 <- grep(end_reg, x))) (i2 + 1)[grepl("^\\s*$", x[i2 + 1])] + i3 <- c( + i3, + if (length(i2 <- grep(end_reg, x))) { + (i2 + 1)[grepl("^\\s*$", x[i2 + 1])] + } ) - if (length(i3)) x = x[-i3] + if (length(i3)) x <- x[-i3] x } diff --git a/R/thesisdown.R b/R/thesisdown.R index 4d1a940f..f32b2d6a 100644 --- a/R/thesisdown.R +++ b/R/thesisdown.R @@ -1,5 +1,5 @@ #' thesisdown: A package for creating undergraduate, Masters, and PhD theses -#'using R Markdown +#' using R Markdown #' #' #' @section thesis_gitbook: diff --git a/inst/rmarkdown/templates/thesis/skeleton/00--prelim.Rmd b/inst/rmarkdown/templates/thesis/skeleton/00--prelim.Rmd deleted file mode 100644 index 369af4f9..00000000 --- a/inst/rmarkdown/templates/thesis/skeleton/00--prelim.Rmd +++ /dev/null @@ -1,16 +0,0 @@ -# Preliminary Content {-} - -## Acknowledgements {-} - -I want to thank a few people. - -## Preface {-} - -This is an example of a thesis setup to use the reed thesis document class -(for LaTeX) and the R bookdown package, in general. - -## Dedication {-} - -You can have a dedication here if you wish. - -`r if(!knitr:::is_latex_output()) '## Abstract {-}'` diff --git a/inst/rmarkdown/templates/thesis/skeleton/00-abstract.Rmd b/inst/rmarkdown/templates/thesis/skeleton/00-abstract.Rmd deleted file mode 100644 index 5aaf6a75..00000000 --- a/inst/rmarkdown/templates/thesis/skeleton/00-abstract.Rmd +++ /dev/null @@ -1,3 +0,0 @@ -The preface pretty much says it all. \par - -Second paragraph of abstract starts here. diff --git a/inst/rmarkdown/templates/thesis/skeleton/01-chap1.Rmd b/inst/rmarkdown/templates/thesis/skeleton/01-chap1.Rmd index 4d364df6..4a7b0958 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/01-chap1.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/01-chap1.Rmd @@ -120,8 +120,9 @@ pkg <- c("dplyr", "ggplot2", "knitr", "bookdown", "devtools") new.pkg <- pkg[!(pkg %in% installed.packages())] # If there are any packages in the list that aren't installed, # install them -if (length(new.pkg)) +if (length(new.pkg)) { install.packages(new.pkg, repos = "http://cran.rstudio.com") +} # Load packages (thesisdown will load all of the packages as well) library(thesisdown) ``` @@ -135,9 +136,9 @@ The example we show here does the following: - Using `flights2`, we determine the largest arrival delay for each of the carriers. ```{r max_delays} -flights2 <- flights %>% +flights2 <- flights %>% select(carrier_name, arr_delay) -max_delays <- flights2 %>% +max_delays <- flights2 %>% group_by(carrier_name) %>% summarize(max_arr_delay = max(arr_delay, na.rm = TRUE)) ``` @@ -145,12 +146,13 @@ max_delays <- flights2 %>% A useful function in the `knitr` package for making nice tables in _R Markdown_ is called `kable`. It is much easier to use than manually entering values into a table by copying and pasting values into Excel or LaTeX. This again goes to show how nice reproducible documents can be! (Note the use of `results="asis"`, which will produce the table instead of the code to create the table.) The `caption.short` argument is used to include a shorter title to appear in the List of Tables. ```{r maxdelays, results="asis"} -kable(max_delays, - col.names = c("Airline", "Max Arrival Delay"), - caption = "Maximum Delays by Airline", - caption.short = "Max Delays by Airline", - longtable = TRUE, - booktabs = TRUE) +kable(max_delays, + col.names = c("Airline", "Max Arrival Delay"), + caption = "Maximum Delays by Airline", + caption.short = "Max Delays by Airline", + longtable = TRUE, + booktabs = TRUE +) ``` The last two options make the table a little easier-to-read. @@ -159,17 +161,24 @@ We can further look into the properties of the largest value here for American A ```{r max_props} -flights %>% filter(arr_delay == 1539, - carrier_name == "American Airlines Inc.") %>% - select(-c(month, day, carrier, dest_name, hour, - minute, carrier_name, arr_delay)) +flights %>% + filter( + arr_delay == 1539, + carrier_name == "American Airlines Inc." + ) %>% + select(-c( + month, day, carrier, dest_name, hour, + minute, carrier_name, arr_delay + )) ``` We see that the flight occurred on March 3rd and departed a little after 2 PM on its way to Dallas/Fort Worth. Lastly, we show how we can visualize the arrival delay of all departing flights from Portland on March 3rd against time of departure. ```{r march3plot, fig.height=3, fig.width=6} -flights %>% filter(month == 3, day == 3) %>% - ggplot(aes(x = dep_time, y = arr_delay)) + geom_point() +flights %>% + filter(month == 3, day == 3) %>% + ggplot(aes(x = dep_time, y = arr_delay)) + + geom_point() ``` ## Additional resources diff --git a/inst/rmarkdown/templates/thesis/skeleton/03-chap3.Rmd b/inst/rmarkdown/templates/thesis/skeleton/03-chap3.Rmd index a74cf94e..021f1b6d 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/03-chap3.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/03-chap3.Rmd @@ -3,18 +3,67 @@ # installed and loaded. This thesisdown package includes # the template files for the thesis and also two functions # used for labeling and referencing -if(!require(devtools)) - install.packages("devtools", repos = "http://cran.rstudio.com") -if(!require(dplyr)) - install.packages("dplyr", repos = "http://cran.rstudio.com") -if(!require(ggplot2)) - install.packages("ggplot2", repos = "http://cran.rstudio.com") -if(!require(ggplot2)) - install.packages("bookdown", repos = "http://cran.rstudio.com") -if(!require(thesisdown)){ - library(devtools) - devtools::install_github("ismayc/thesisdown") +if (!require(remotes)) { + if (params$`Install needed packages for {thesisdown}`) { + install.packages("remotes", repos = "https://cran.rstudio.com") + } else { + stop( + paste( + 'You need to run install.packages("remotes")', + "first in the Console." + ) + ) } +} +if (!require(dplyr)) { + if (params$`Install needed packages for {thesisdown}`) { + install.packages("dplyr", repos = "https://cran.rstudio.com") + } else { + stop( + paste( + 'You need to run install.packages("dplyr")', + "first in the Console." + ) + ) + } +} +if (!require(ggplot2)) { + if (params$`Install needed packages for {thesisdown}`) { + install.packages("ggplot2", repos = "https://cran.rstudio.com") + } else { + stop( + paste( + 'You need to run install.packages("ggplot2")', + "first in the Console." + ) + ) + } +} +if (!require(bookdown)) { + if (params$`Install needed packages for {thesisdown}`) { + install.packages("bookdown", repos = "https://cran.rstudio.com") + } else { + stop( + paste( + 'You need to run install.packages("bookdown")', + "first in the Console." + ) + ) + } +} +if (!require(thesisdown)) { + if (params$`Install needed packages for {thesisdown}`) { + remotes::install_github("ismayc/thesisdown") + } else { + stop( + paste( + "You need to run", + 'remotes::install_github("ismayc/thesisdown")', + "first in the Console." + ) + ) + } +} library(thesisdown) flights <- read.csv("data/flights.csv") ``` @@ -77,7 +126,8 @@ Here is a reference to the Reed logo: Figure \@ref(fig:reedlogo). Note the use Below we will investigate how to save the output of an **R** plot and label it in a way similar to that done above. Recall the `flights` dataset from Chapter \@ref(rmd-basics). (Note that we've shown a different way to reference a section or chapter here.) We will next explore a bar graph with the mean flight departure delays by airline from Portland for 2014. Note also the use of the `scale` parameter which is discussed on the next page. ```{r delaysboxplot, warnings=FALSE, messages=FALSE, fig.cap="Mean Delays by Airline", fig.width=6} -flights %>% group_by(carrier) %>% +flights %>% + group_by(carrier) %>% summarize(mean_dep_delay = mean(dep_delay)) %>% ggplot(aes(x = carrier, y = mean_dep_delay)) + geom_bar(position = "identity", stat = "identity", fill = "red") diff --git a/inst/rmarkdown/templates/thesis/skeleton/05-appendix.Rmd b/inst/rmarkdown/templates/thesis/skeleton/05-appendix.Rmd index c57f9ff9..b6e5a239 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/05-appendix.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/05-appendix.Rmd @@ -2,13 +2,13 @@ `r if(!knitr:::is_latex_output()) '# (APPENDIX) Appendix {-}'` + +# The First Appendix + - -# The First Appendix - This first appendix includes all of the R chunks of code that were hidden throughout the document (using the `include = FALSE` chunk tag) to help with readibility and/or setup. **In the main Rmd file** diff --git a/inst/rmarkdown/templates/thesis/skeleton/_bookdown.yml b/inst/rmarkdown/templates/thesis/skeleton/_bookdown.yml index bd6db3d4..38da024b 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/_bookdown.yml +++ b/inst/rmarkdown/templates/thesis/skeleton/_bookdown.yml @@ -1,5 +1,8 @@ book_filename: "thesis" chapter_name: "Chapter " -rmd_files: ["index.Rmd", "01-chap1.Rmd", "02-chap2.Rmd", "03-chap3.Rmd", "04-conclusion.Rmd", "05-appendix.Rmd", "99-references.Rmd"] -download: [["thesis.pdf", "PDF"], ["thesis.epub", "EPUB"], ["thesis.docx", "Word"]] +download: [ + ["thesis.pdf", "PDF"], + ["thesis.epub", "EPUB"], + ["thesis.docx", "Word"] + ] delete_merged_file: true diff --git a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd index 1f6d9af9..b1333274 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd @@ -20,8 +20,8 @@ params: # Remove the hashtag to specify which version of output you would like. # Can only choose one at a time. output: -# thesisdown::thesis_pdf: default - thesisdown::thesis_gitbook: default + thesisdown::thesis_pdf: default +# thesisdown::thesis_gitbook: default # thesisdown::thesis_word: default # thesisdown::thesis_epub: default @@ -92,10 +92,6 @@ if (!require(thesisdown)) { library(thesisdown) ``` - - -Below we will investigate how to save the output of an **R** plot and label it in a way similar to that done above. Recall the `flights` dataset from Chapter \@ref(rmd-basics). (Note that we've shown a different way to reference a section or chapter here.) We will next explore a bar graph with the mean flight departure delays by airline from Portland for 2014. Note also the use of the `scale` parameter which is discussed on the next page. +Below we will investigate how to save the output of an **R** plot and label it in a way similar to that done above. Recall the `flights` dataset from Chapter \@ref(rmd-basics). (Note that we've shown a different way to reference a section or chapter here.) We will next explore a bar graph with the mean flight departure delays by airline from Portland for 2014. ```{r delaysboxplot, warnings=FALSE, messages=FALSE, fig.cap="Mean Delays by Airline", fig.width=6} -flights %>% +mean_delay_by_carrier <- flights %>% group_by(carrier) %>% - summarize(mean_dep_delay = mean(dep_delay)) %>% - ggplot(aes(x = carrier, y = mean_dep_delay)) + + summarize(mean_dep_delay = mean(dep_delay)) +ggplot(mean_delay_by_carrier, aes(x = carrier, y = mean_dep_delay)) + geom_bar(position = "identity", stat = "identity", fill = "red") ``` @@ -163,13 +163,17 @@ You might want to footnote something. ^[footnote text] The footnote will be in a ## Bibliographies -Of course you will need to cite things, and you will probably accumulate an armful of sources. There are a variety of tools available for creating a bibliography database (stored with the .bib extension). In addition to BibTeX suggested below, you may want to consider using the free and easy-to-use tool called Zotero. The Reed librarians have created Zotero documentation at . In addition, a tutorial is available from Middlebury College at . +Of course you will need to cite things, and you will probably accumulate an armful of sources. There are a variety of tools available for creating a bibliography database (stored with the .bib extension). In addition to BibTeX suggested below, you may want to consider using the free and easy-to-use tool called Zotero. The Reed librarians have created Zotero documentation at . In addition, a tutorial is available from Middlebury College at . -_R Markdown_ uses _pandoc_ () to build its bibliographies. One nice caveat of this is that you won't have to do a second compile to load in references as standard LaTeX requires. To cite references in your thesis (after creating your bibliography database), place the reference name inside square brackets and precede it by the "at" symbol. For example, here's a reference to a book about worrying: [@Molina1994]. This `Molina1994` entry appears in a file called `thesis.bib` in the `bib` folder. This bibliography database file was created by a program called BibTeX. You can call this file something else if you like (look at the YAML header in the main .Rmd file) and, by default, is to placed in the `bib` folder. +_R Markdown_ uses _pandoc_ () to build its bibliographies. One nice caveat of this is that you won't have to do a second compile to load in references as standard LaTeX requires. To cite references in your thesis (after creating your bibliography database), place the reference name inside square brackets and precede it by the "at" symbol. For example, here's a reference to a book about worrying: [@Molina1994]. This `Molina1994` entry appears in a file called `thesis.bib` in the `bib` folder. This bibliography database file was created by a program called BibTeX. You can call this file something else if you like (look at the YAML header in the main .Rmd file) and, by default, is to placed in the `bib` folder. -For more information about BibTeX and bibliographies, see our CUS site ()^[@reedweb2007]. There are three pages on this topic: _bibtex_ (which talks about using BibTeX, at ), _bibtexstyles_ (about how to find and use the bibliography style that best suits your needs, at ) and _bibman_ (which covers how to make and maintain a bibliography by hand, without BibTeX, at ). The last page will not be useful unless you have only a few sources. +For more information about BibTeX and bibliographies, see our CUS site ()^[@reedweb2007]. There are three pages on this topic: _bibtex_ (which talks about using BibTeX, at ), _bibtexstyles_ (about how to find and use the bibliography style that best suits your needs, at ) and _bibman_ (which covers how to make and maintain a bibliography by hand, without BibTeX, at ). The last page will not be useful unless you have only a few sources. -If you look at the YAML header at the top of the main .Rmd file you can see that we can specify the style of the bibliography by referencing the appropriate csl file. You can download a variety of different style files at . Make sure to download the file into the csl folder. +If you look at the YAML header at the top of the main .Rmd file you can see that we can specify the style of the bibliography by referencing the appropriate csl file. You can download a variety of different style files at . Make sure to download the file into the csl folder. + + + +\vfill **Tips for Bibliographies** diff --git a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd index b1333274..28e10fc1 100644 --- a/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/thesis/skeleton/skeleton.Rmd @@ -62,7 +62,7 @@ If you'd like to include a comment that won't be produced in your resulting file If you receive a duplicate label error after knitting, make sure to delete the index.Rmd file and then knit again. --> -```{r include_packages, include = FALSE} +```{r include_packages, include=FALSE} # This chunk ensures that the thesisdown package is # installed and loaded. This thesisdown package includes # the template files for the thesis. @@ -90,6 +90,8 @@ if (!require(thesisdown)) { } } library(thesisdown) +# Set how wide the R output will go +options(width = 70) ```