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?
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$
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With