Search code examples
pdfmarkdownquarto

Separate bibliographies per chapter in Quarto (PDF output)


I like to have multiple bibliographies in a Quarto document (PDF output). Could you give me a hint what is wrong with this code? (I've tried the refsection evironment from biblatex Separate bibliographies per chapter? )

---
title: "resize image"
bibliography: refs.bib 
format: pdf
header-includes:
  \usepackage{biblatex}
---

\begin{refsection}
Text \cite{ref1}
\printbibliography
\end{refsection}

Produces strange output like: Text [ref1]


Solution

  • Update (using pandoc filter)

    Using the pandoc filter section-bibliographies as a Quarto Extension, provided by @tarleb, section-wise bibliographies can be created more neatly.

    ---
    title: "Sectionwise Bibliography"
    bibliography: pkg.bib 
    format: pdf
    keep-tex: true
    filters:
      - section-bibliographies
    reference-section-title: References
    ---
    
    # Quarto
    
    Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
    
    [see @R-knitr]
    
    # Running Code
    
    When you click the **Render** button a document will be generated that includes both content and the output of embedded code. 
    
    [see @R-ggplot2]
    
    

    using pandoc filter section-bibliographies


    Using Latex

    Quarto itself has an option cite-method to specify to use the biblatex as the citation manager.

    ---
    title: "resize image"
    bibliography: pkg.bib 
    format: pdf
    cite-method: biblatex
    biblatexoptions:
      - citestyle = authoryear
    ---
    
    \begin{refsection}
    Text \cite{R-knitr}
    \printbibliography
    \end{refsection}
    

    chapter wise referencing with biblatex


    Contents of the associated pkg.bib file,

    @Manual{R-ggplot2,
      title = {ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics},
      author = {Hadley Wickham and Winston Chang and Lionel Henry and Thomas Lin Pedersen and Kohske Takahashi and Claus Wilke and Kara Woo and Hiroaki Yutani and Dewey Dunnington},
      year = {2022},
      note = {https://ggplot2.tidyverse.org},
    }
    
    @Manual{R-knitr,
      title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
      author = {Yihui Xie},
      year = {2022},
      note = {R package version 1.39},
      url = {https://yihui.org/knitr/},
    }