quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
315 stars 26 forks source link

Feature Request: Option to Suppress Automatic Bibliography in PDF Output #386

Open olearydj opened 7 months ago

olearydj commented 7 months ago

I'm currently using Quarto to generate both HTML and PDF documents from the same source. For the PDF version, I need to manually manage the bibliography using biblatex and biber due to specific formatting requirements and the need for back-references. However, I've encountered an issue where Quarto automatically generates a bibliography section at the end of my PDF documents, despite my custom configuration. This results in the bibliography being duplicated: once where I have manually inserted it using LaTeX commands, and once automatically by Quarto.

I would like an option in the Quarto configuration that allows me to suppress the automatic bibliography generation when rendering to PDF. This option would prevent Quarto from automatically adding a bibliography section, enabling me to fully control the bibliography placement and formatting through LaTeX.

For example, an option in the _quarto.yml could be:

pdf:
  bibliography: none  # or some similar keyword to indicate suppression

I have tried various workarounds, such as modifying the LaTeX template to remove bibliography commands. However, these methods have not been successful in preventing the automatic inclusion of the bibliography by Quarto. It seems like the bibliography rendering is done outside of the config files.

Here are the relevant sections of my _quarto.yml file; some sections omitted (...) for brevity:

book:
...
  chapters:
    - index.qmd
...
    - 27-references.qmd
  appendices:
    - 31-irb.qmd
...

bibliography: references.bib
csl: "csl/apa7-single-spaced.csl"

...

  pdf:
    link-citations: true
    cite-method: "biblatex"
    biblio-style: "apa"
    biblatexoptions: 
      - "backend=biber"
      - "backref=true"
    template: tex/template.tex

Options for html output are included in the same file, but nothing else specific to bibliography generation. I normally render to HTML for a quick preview, and occasionally to PDF.

Here are the contents of 27-references.qmd which is used to generate the appropriate content based on render target:

::: {.unlisted #27-references}
# References

<!-- For PDF output -->
::: {#refs .latex}
\begingroup
\raggedright
\printbibliography[heading=none]
\endgroup
:::

<!-- For HTML output -->
::: {#refs .html}
:::
:::

That last bit is pretty damn clever, if I do say so myself. H/T to ChatGPT4 for being a know-it-all. I spoke too soon. That code doesn't seem to work after all. I've just reverted to this:

# References {#27-references .unnumbered}

\begingroup
\raggedright
\printbibliography[heading=none]
\endgroup

For PDF, this approach renders the biblatex references twice, once where I've inserted it, and again at the end of everything else. It leaves the references empty when rendering to HTML.

Thanks!

cscheid commented 7 months ago

Try taking a look at https://quarto.org/docs/authoring/conditional.html

olearydj commented 7 months ago

Great, thank you. I'm happy to report that this works a treat for rendering references using citeproc for HTML output and biblatex for PDF.

Unfortunately, I'm still stuck with the original problem - there doesn't appear to be a way to suppress the second bib generation at the end of the doc. Can you confirm?

PS - Quarto is so amazing. Just a joy to work with. Thanks to you and the entire team!

# References {#27-references .unnumbered}

::: {#refs .content-visible when-format="html"}
:::

::: {.content-visible when-format="pdf"}

\begingroup
\raggedright
\printbibliography[heading=none]
\endgroup

:::