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:

    ---
    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.