r-markdownpandocbookdowncslpandoc-citeproc

RMarkdown/Bookdown: Output specific CSL (citation style)


Is there a possibility to specify different citation style language (CSL) files in (the YAML header of) RMarkdown?

I tried

---
output:
  bookdown::word_document2:
    csl: style_1.csl
  bookdown::pdf_book:
    csl: style_2.csl
---

but it doesn't result in different citation styles in the different output formats.


Solution

  • No, you can't do it like that. csl isn't an argument to the bookdown::word_document2 function, or rmarkdown::word_document.

    The csl: entry in the YAML needs to be at the top level, and is handled by Pandoc. It might be possible to include it in the pandoc_args argument to the driver functions, but the normal way is to use csl: style.csl at the top level, so you'd get the same style for both output formats.

    Edited to add:

    From your comment, pandoc_args does work. You would use YAML like this:

    ---
    output:
      bookdown::word_document2:
        pandoc_args: ["--csl=style_1.csl"]
      bookdown::pdf_book:
        pandoc_args: ["--csl=style_2.csl"]
    ---