create references in each section in Rmarkdown

橙三吉。 提交于 2021-02-07 09:01:07

问题


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?


回答1:


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}
:::


来源:https://stackoverflow.com/questions/41001100/create-references-in-each-section-in-rmarkdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!