Pandoc insert appendix after bibliography Pandoc insert appendix after bibliography r r

Pandoc insert appendix after bibliography


With newer pandoc versions, you can specify the bibliography's position with <div id="refs"></div> source

This is some text [@item1]This is more text [@item2]# References<div id="refs"></div># appendix


Eventually reference handling will change to make it possible to put the references wherever you like (https://github.com/jgm/pandoc/issues/771), but right now there's no easy way to do it.

As suggested here, you could put your appendix in a separate file, use pandoc to convert it to a LaTeX fragment, then include that fragment using the --include-after-body flag. It would then come after the bibliography.


When working in an Rmarkdown document, enter the following text where the citations are to be located. It can be placed in any part of the document allowing other materials, like an appendix, to follow as necessary. The method relies on pandoc's fenced divs which will work in Rmarkdown.

::: {#refs}:::

The aforementioned code should not be in an R code chunk, rather it should be placed on blank lines by themselves. Once processed by pandoc via knitter, this code will produce the same result as <div id="refs"></div> mentioned in the answer by @soca. The two lines of code do consistently allow for exact placement of the references in any section of the document.

In the example below, references are placed first under a heading of the same name while all of the code chunks in the document are placed afterwards in a code appendix. Here is the pandoc fenced div placed in Rmarkdown that can be used to generate the image that follows.

# References::: {#refs}:::# Appendix A: R Code```{r ref.label=knitr::all_labels(), echo=TRUE, eval=FALSE}```

Provided there is a .bib file identified in the yaml frontmatter, the preceding Rmarkdown produces output similar to the following:enter image description here

Helpful links: