create references in each section in Rmarkdown
Asked Answered
A

1

7

I want to use Rmarkdown but what I've read is that when creating a bibliography using pandoc, references go at the end of the document:

pandoc/citeproc issues: multiple bibliographies, nocite, citeonly

So even if I have a parent document named thesis.Rmd, I assume that all references would go at the end of that file.

I need that each thesis' chapter or section must have its own references, is there any other way to solve this than putting a bibliography header in each chapter I write and then knit each chapter separetely?

Alden answered 6/12, 2016 at 17:13 Comment(2)
AFAIK there is no way to do this. I had a simpler problem (moving the biblio section before the appendix section) and had to write a quick pandoc filter just for that.Immunology
@SergioCorreia apparently I'm going to need and appendix after my biblio section, could you please explain what is a pandoc filter for this and how does it work?Alden
T
2

It is possible using multiple-bibliographies.lua filter. However, .bib files should be chapter-specific.

Note: after pandoc >= 2.11 each chapter accepts only one .bib file as in this example

---
title: "Doc title"
author: "name name"
date: "23 08 2019"
output:
  html_document:
    toc: true
    toc_depth: 1
    number_sections: true
    pandoc_args: --lua-filter=multiple-bibliographies.lua

bibliography_chapter1: [chapter1.bib]
bibliography_chapter2: [chapter2.bib]
bibliography_chapter3: [chapter3.bib]    
csl: format.csl
link-citations: yes
---

At the end of each chapter add:

## References {-}

::: {#refs_chapterX}
:::
Theobald answered 1/1, 2020 at 21:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.