6

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 ?

bretauv
  • 7,756
  • 2
  • 20
  • 57

2 Answers2

5

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 
bretauv
  • 7,756
  • 2
  • 20
  • 57
3

If using

citation_package: biblatex

you can include the bibliography at an arbitrary point using

\printbibliography

This does not, of itself, stop pandoc adding a (further) end-of-document bibliography, but since pandoc ignores latex in non-latex output, we can suppress that by redefining \printbibliography on the fly to do nothing.

So try this, for a references section preceding an Appendix:

# References

<div id="refs"></div>
\printbibliography[heading=none]
\def\printbibliography{}

# Appendix 1

Appendix goes here, and is not followed by a bibliography.
S Ellison
  • 401
  • 3
  • 5
  • This solution works great when using `citation_package: biblatex`, but I don't think it is necessary to add `
    `, as the `\printbibliography` command is doing the same thing. In my case, including that div command meant that it appeared verbatim at the top of my reference list.
    – Juan David Leongomez Apr 04 '23 at 17:13