Often, scientific journal websites and other sources offer downloadable *.bib
files for referring to individual articles. If I use these, I like to keep them as they are instead of merging them into a single file. On the command line, several files can be specified by passing the --bibliography
option multiple times. Can I also list multiple files in the YAML metadata inside the *.md
document itself?
2 Answers
If you want to use biblatex for a citation formatter, you can set up multiple bib files in your YAML front matter:
---
bibliography:
- mybib1.bib
- mybib2.bib
---
You'll need to compile with:
pandoc myfile.md -o myfile.pdf --biblatex
This works because the latex templates contains a $for(bibliography)$
loop:
$if(biblatex)$
\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$
$for(bibliography)$
\addbibresource{$bibliography$}
$endfor$
$endif$

- 19,359
- 5
- 65
- 80
-
1Can I use biblatex regardless of the output format? I'd like to be able to produce both PDFs and Word Documents (`*.docx`). – das-g Apr 26 '17 at 09:13
-
3No, you have to use pandoc-citeproc for output format other than latex/beamer. – scoa Apr 26 '17 at 09:39
-
@tarleb Can you make an answer of the information in your comment? – das-g Sep 14 '18 at 07:57
Bibliographies can be specified in document metadata, i.e. via for Markdown in YAML blocks:
---
bibliography:
- one.bib
- two.bib
- three.bib
---
This only works if pandoc-citeproc
is invoked as a filter by passing --filter=pandoc-citeproc
on the command line. E.g.,
$ pandoc --filter=pandoc-citeproc --from=markdown --to=latex my-file.md
To understand why, we must take a step back and look at the way pandoc handles citations. Usually, i.e. if no alternative citation method has been requested via --natbib
or --biblatex
, pandoc uses pandoc-citeproc to handle citations, ensuring comparable citation handling across different formats. pandoc-citeproc
works as a pandoc filter: the program receives the full document in pandoc's JSON format and performs the following steps:
- get the bibliography file(s) from the bibliography metadata field;
- collect all citations in the document;
- create a bibliography and insert appropriate text in the document;
- encode the resulting document to JSON again and write to stdout.
Pandoc will then continue its work using the modified document.
The bibliography
field can be set either via the command line or in the document itself. The only difference between using command line options or YAML metadata is that pandoc invokes pandoc-citeproc
automatically if the bibliography is given as a CLI parameter. Since we don't want this, we need to tell pandoc explicitly that the pandoc-citeproc filter must be called.

- 19,863
- 4
- 51
- 80