Search code examples
luapandocquartobibliography

Quarto - Apply different styles to different bibliographies


Using the multibib filter, it is possible to insert several bibliographies in a Quarto document, like this:

---
format:
  pdf
filters: 
  - multibib
title: "Test"
csl: elsevier-harvard.csl

# Turn off YAML validation
validate-yaml: false

bibliography:
  main: references.bib
  lit: literature.bib 

# Disable citeproc
citeproc: false
---


# Main text

@bb

@aa

# Bibliography

::: {#refs-main}
:::

# Appendix

::: {#refs-lit}
:::

with references.bib containing:

@Article{aa,
  author =   {Author, A.},
  title =    {Title},
  journal =  {Journal},
  year =     2000
}

and literature.bib containing;

@Article{bb,
  author =   {Brother, B.},
  title =    {Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling Titling},
  journal =  {Ann. J.},
  year =     2002
}

Would it be possible to apply different styles to each bibliography and their corresponding citations? For example, to get one main bibliography with authoryear citation and ordered by Author name, and one second bibliography in Appendix with numbered citation and ordered by numbers. I think this is can be a quite frequent use case.

In the quarto YAML header, only one .csl file can be used to define the style of the whole document. Would there be a relatively simple approach to use two .csl files? Or another approach without .csl files?

Maybe that would be only possible with a more elaborate approach with LaTeX?


Solution

  • It seems it is not possible at the moment with the multibib filter only and a full markdown/quarto solution.

    I was able to get two bibliographies with different styles using:

    • multibib with markdown citations (@aa) for one type of citation (numbered refs in the capture below), using the .csl file loaded in the YAML header.
    • LaTeX citations (\cite{bb}) using the citation-style-language LaTeX package to load the second .csl file. The different style can be applied to a section of the document using the newrefsection tag.
    • the lualatex engine
    ---
    format:
      pdf:
        keep-tex: true
        include-in-header:
          text: |
            \usepackage{citation-style-language}
            \addbibresource{references.bib}
    pdf-engine: lualatex
    
    filters: 
      - multibib
    title: "Test"
    csl: american-chemical-society.csl
    
    # Turn off YAML validation
    validate-yaml: false
    
    bibliography:
      lit: literature.bib
    
    # Disable citeproc
    citeproc: false
    ---
    
    \newrefsection[style = elsevier-harvard, bib-resource = references]
    
    # Main text
    
    Citation with author-year \cite{bb}.
    
    Numbered citation. @aa
    
    # Bibliography
    
    \printbibliography[heading=none]
    \endrefsection
    
    # Appendix
    
    ::: {#refs-lit}
    :::
    
    

    capturedresult

    Not a perfect solution because of the two types of citation systems, but quite easy to use.