How to Get a Second Bibliography

rmarkdown: how to use multiple bibliographies for a document

For the record: I raised this as an issue for pandoc-citeproc at https://github.com/jgm/pandoc-citeproc/issues/220

It turns out that there were problems in how pandoc-citeproc handles some characters in @{string={}} and non-ASCII characters in .bib files, so what I was trying now works, with hard-coded pathnames, in all the forms I tried.

To make it work more like processing of .Rnw files via Latex/bibtex it would be nice to be able to use something like

bibliography: 
- `r system(kpsewhich statistics.bib)`
- `r system(kpsewhich graphics.bib)`

Those commands do find the right files in an R session, but not from a YAML header.

How to insert two separate bibliographies (without citing them in the body text) under two separate headers in R Markdown?

You could use biblatex to split the bibliographies:

---
title: 'John Doe'
output:
pdf_document:
keep_tex: true
csl: vancouver.csl
header-includes:
- \include{preamble.tex}
---

with preamble.tex:

\usepackage[style=vancouver]{biblatex}
\addbibresource{bib1.bib}
\addbibresource{bib2.bib}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\perdatasource{bib1.bib}
\step[fieldset=keywords, fieldvalue={,peer}, append]
}
}
}

\AtEndDocument{\nocite{*}
\printbibliography[keyword={peer},title={Peer-reviewed publications}]
\DeclareFieldFormat{labelnumber}{%
\ifinteger{#1}
{\number\numexpr#1-2\relax}
{#1}}
\printbibliography[notkeyword={peer},title={Other publications}]}

And then compile the resulting filename.tex file with

pdflatex filename
biber filename
pdflatex filename

Sample Image

Include extra bibliography in R Markdown

The contents of an external Word file can be included in R Markdown via officer::block_pour_docx. I used Zotero to generate a Word bibliography based on pacakges.bib and then the following to include in my document:

```{r}
block_pour_docx("packages.docx")
```

CSL file not applied everywhere when having two bibliographies

The solution can be found in the comments of this answer. The only thing to do is to replace:

local tmp_meta = pandoc.Meta{bibliography = doc_meta['bibliography' .. name]}

by

local tmp_meta = pandoc.Meta{bibliography = doc_meta['bibliography' .. name], csl = doc_meta.csl}

in multiple-bibliographies.lua

Rmarkdown: how to import all the *.bib files in a directory for bibliography?

You can do this, but it's a little tricky. What Pandoc wants to see in the bibliography field is something like

bibliography: ["file1.bib", "file2.bib"]

I can get that with this code:

bibliography: ["`r paste(c('file1.bib', 'file2.bib'), collapse='\",\"')`"]

Given your updated structure of the directory, I think this should work:

bibliography: ["`r paste(list.files(path = './includes', pattern = '^.+\\.bib$', full.names = TRUE), collapse='\",\"')`"]

The list.files() call will give you usable names, you don't need to modify it.



Related Topics



Leave a reply



Submit