CSL file not applied everywhere when having two bibliographies

Following this answer about having two bibliographies in an R Markdown document, I just saw that CSL files are not applied everywhere.

Indeed, in the example below:

title: "Cite R packages"
author: ''
date: ""
    pandoc_args: --lua-filter=multiple-bibliographies.lua
bibliography_software: packages.bib
bibliography_normal: test.bib
csl: anabases.csl

This is a citation of a paper: @mayer2011.
This is a citation of an R package @R-dplyr
And another @R-knitr

# Bibliography{-}
<div id = "refs_normal"></div>

# Software used{-}
<div id = "refs_software"></div>

```{r cite-packages, echo=FALSE}

packages_used <- c("dplyr", "ggplot2", "knitr")

knitr::write_bib(packages_used, file = "packages.bib", tweak = TRUE)


To prevent having a post too long, see here for the contents of multiple-bibliographies.lua and test.bib (packages.bib is created at the end of the .Rmd file).

In this example, I use anabases.csl just because it is easy to see if the csl file was applied or not. You can see what it looks like and download it here. The problem is this R Markdown file applies csl on the citations in text but not on the bibliographies. In the picture below, you can see that capitals are applied on the citations in text but not in the bibliographies, whereas it should be the case.

Why is that? How can I apply csl everywhere in the document?

I think this has to be done in the .lua file but not sure at all.

Also asked on StackOverflow

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]}


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

in multiple-bibliographies.lua

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