Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Markdown: place an Appendix after the "References" section?

Tags:

r

r-markdown

I am writing a report with R Markdown in which I include references. The problem is that R markdown automatically places references at the end of the report. I would like to place an Appendix after the references, is there a way to do it? I saw that it is possible with a child document but I would like to have everything in a unique .Rmd file.

Below is a reproducible example:

---
title:
author:
date: 
abstract: 

output: 
  pdf_document:
    template: NULL
    number_sections: true
    citation_package: biblatex
bibliography: references.bib
biblio-style: bwl-FU
---

# Partie 1

\cite{greenwood_financial_1989}

<!-- where I would like the references to be -->

# Appendix

bla bla 

and here is the content of the references.bib file:

@article{greenwood_financial_1989,
  title = {Financial Development, Growth and the Distribution of Income},
  url = {https://www.nber.org/papers/w3189},
  number = {3189},
  journaltitle = {NBER Working Paper Series},
  date = {1989},
  author = {Greenwood, Jeremy and Jovanovic, Boyan}
}

Any idea ?

like image 927
bretauv Avatar asked Oct 01 '19 14:10

bretauv


People also ask

How do you add a reference in R Markdown?

The usual way to include citations in an R Markdown document is to put references in a plain text file with the extension . bib, in BibTex format. Then reference the path to this file in index. Rmd's YAML header with bibliography: example.

What does ## do in R Markdown?

headers - Place one or more hashtags at the start of a line that will be a header (or sub-header). For example, # Say Hello to markdown . A single hashtag creates a first level header. Two hashtags, ## , creates a second level header, and so on.

How do you add a footnote in R Markdown?

To create a footnote in R Markdown, you use the carrot ^ followed immediately by square brackets []. Put the text inside of the [] and it'll print that at the bottom of the page. Code for a footnote will look like this: ^[This sentence will be printed as a footnote.] .

How do you cite a Bookdown?

To cite an entry, use @key or [@key] (the latter puts the citation in braces), e.g., @R-base is rendered as R Core Team (2022), and [@R-base] generates “(R Core Team 2022)”. A note can be included within the square brackets, e.g., [a note about, @R-base] will be rendered as “(a note about, R Core Team 2022)”.


1 Answers

This is explained in the R Markdown Cookbook (section 3.5.4). We can force the bibliography to be printed at a particular place with:

# References

<div id="refs"></div>

# Appendix

Note that:

  • this works if we cite the papers with @id_of_paper (which is the recommended way in R Markdown) but not with \cite{id_of_paper}.
  • this does not work if we use citation_package: biblatex in YAML

Here's my adapted example:

---
title:
author:
date: 
abstract: 
output: 
  pdf_document:
    template: NULL
    number_sections: true
bibliography: references.bib
biblio-style: bwl-FU
---

# Partie 1

@greenwood_financial_1989


# References

<div id="refs"></div>


# Appendix

bla bla 
like image 62
bretauv Avatar answered Oct 03 '22 20:10

bretauv