arm-workshop-rsc2019 icon indicating copy to clipboard operation
arm-workshop-rsc2019 copied to clipboard

Can you expand on the explanation of how references are processed in bookdown?

Open skolenik opened this issue 5 years ago • 1 comments

Are there YAML options to control where references are placed? E.g. if I want to put them before appendices, what is the way to configure that? (Your 06-references.Rmd only says, "References", and it looks like it is simply a placeholder used in understanding that the references always come last.)

skolenik avatar Jan 15 '19 21:01 skolenik

Yes.

First, I'll be following the skeleton bookdown (https://skeleton-bookdown.netlify.com/; https://github.com/rstudio-education/armcompanion/tree/master/bookdown/skeleton-bookdown).

  1. Open the index.Rmd. Notice this code in the YAML:

    bibliography: [book.bib, packages.bib]
    
  2. Scroll down in the same index.Rmd and notice this code chunk, which dynamically generates a bibliography of the packages used and adds a few as well, exporting the file to packages.bib:

    # automatically create a bib database for R packages
    knitr::write_bib(c(.packages(), 'bookdown', 'knitr', 'rmarkdown'), 'packages.bib')
    
  3. So we generate packages.bib, and we specify in the index.Rmd YAML that that is one of the .bib files to render in the bibliography.

  4. In the skeleton book, no citations appear "in text" so they end up dumped at the end. So, in the skeleton, the last chapter only adds the level-one chapter header "References", then the bibliography prints directly after.

  5. If you add in-text citations, you can control whether those references show up at the end, or if they get printed at the end of each chapter in the _output.yml file.

    By default, the bibliography is split and relevant citation items are put at the bottom of each page, so that readers do not have to navigate to a different bibliography page to see the details of citations. This feature can be disabled using split_bib = FALSE, in which case all citations are put on a separate page. bookdown book

When the output format is LaTeX, citations will be automatically put in a chapter or section. For non-LaTeX output, you can add an empty chapter as the last chapter of your book. For example, if your last chapter is the Rmd file 06-references.Rmd, its content can be an inline R expression... bookdown book

apreshill avatar Jan 16 '19 17:01 apreshill