Add multiple bibliography files w/ rticles

I'm using the rticles package to write an article for the R Journal using the template. I wanted to enable bookdown cross-references so here is my output format in my YAML:

output:
  bookdown::pdf_book:
    base_format: rticles::rjournal_article

The template created a bibliography file named RJreferences.bib in the project root directory, which is fine. I can knit my document with my references in there. But I would like to layer another .bib file, and cannot figure out how to do this. If I add this to my YAML:

bibliography: RJreferences.bib

I get an error message that seems to boil down to this:

Illegal, another \bibdata command---line 77 of file RJwrapper.aux
 : \bibdata
 :         {RJreferences.bib}
I'm skipping whatever remains of this command
Database file #1: RJreferences.bib

Is there a way to have multiple .bib files in this kind of project? My specific use case is that I'd like to use knitr to create a .bib file with all the packages used in the paper automatically, like this:

knitr::write_bib(.packages(), "packages.bib") 

Then use two .bib files following my own tutorial from the blogdown package (:sob:) here:
https://blogdown-demo.rbind.io/2017/08/28/adding-citations-to-posts/

So ideally I was after:

---
bibliography: [RJreferences.bib, packages.bib]
---

Is this only happening with a bookdown project based on this article format? With this specific format?

Multiple bib files should work in bookdown.

I got the same error, but just realized I failed to see this:

\bibliography{RJreferences}

At the bottom of the template Rmd. Now when I switch to specifying in the YAML I'm able to knit :tada:

Thank you for helping me take a second look :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.