bretauv
bretauv

Reputation: 8557

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

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 ?

Upvotes: 6

Views: 3039

Answers (2)

S Ellison
S Ellison

Reputation: 441

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.

Upvotes: 3

bretauv
bretauv

Reputation: 8557

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 

Upvotes: 5

Related Questions