Rmarkdown: how to use multiple bibliographies for a document

[My environment: Win 7 Pro / R 3.2.1 / knitr_1.12.3 / R Studio Version 0.99.892]

I am trying to write an article in .Rmd format using R Studio, Knit → PDF, and I follow http://rmarkdown.rstudio.com/authoring_bibliographies_and_citations.html for details on how to get pandoc and pandoc-citeproc so that create a section of links and quotes in the text.

My BibTeX links are in several different .bib files, which when using LaTeX in .Rnw files, all are in my local texmf tree via

 \bibliography{statistics, graphics} 

I can not do this work with pandoc-citeproc . My YAML header has the following, which works for the one .bib file if it is in the same directory as the original .Rmd file:

  --- title: "Notes on Testing Equality of Covariance Matrices" author: "Michael Friendly" date: '`r format(Sys.time(), "%B %d, %Y")`' output: pdf_document: fig_caption: yes keep_tex: yes number_sections: yes csl: apa.csl bibliography: statistics.bib --- 

Following the tips in the link above, I tried:

 bibliography: [statistics.bib,graphics.bib] 

this gives:

 pandoc-citeproc.exe: "stdin" (line 50, column 12): unexpected ":" expecting letter, digit, white space or "=" pandoc.exe: Error running filter pandoc-citeproc Filter returned error status 1 

[Edit: for completeness, I show the generated pandoc command, where it looks like both .bib files are transferred correctly]:

 "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS EqCov.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output EqCov.pdf --template "C:\R\R-3.2.1\library\rmarkdown\rmd\latex\default-1.15.2.tex" --number-sections --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --bibliography statistics.bib --bibliography graphics.bib --filter pandoc-citeproc output file: EqCov.knit.md 

So do all of the following forms:

  bibliography: ["statistics.bib","graphics.bib"] bibliography: - "statistics.bib" - "graphics.bib" bibliography: - statistics.bib - graphics.bib 

Ideally, I would like to be able to use one of the following forms and not copy the .bib files to the document directory.

 bibliography: ["C:/Dropbox/localtexmf/bibtex/bib/statistics.bib","C:/Dropbox/localtexmf/bibtex/bib/graphics.bib"] bibliography: - "C:/Dropbox/localtexmf/bibtex/bib/statistics.bib" - "C:/Dropbox/localtexmf/bibtex/bib/graphics.bib" 
+5
source share
1 answer

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

It turns out there were problems with the way pandoc-citeproc handles some characters in @{string={}} and non-ASCII characters in .bib files, so what I'm trying now works with hard-coded path names in all forms I have tried.

To make it more like handling .Rnw files through Latex / bibtex, it would be nice to use something like

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

These commands will find the files you want in the R session, but not from the YAML header.

+1
source

Source: https://habr.com/ru/post/1245706/


All Articles