quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.6k stars 294 forks source link

Infinite compilation loop for PDF format and YAML references support #7353

Open dfolio opened 8 months ago

dfolio commented 8 months ago

Bug description

I try to render a PDF using

cite-method: biblatex
biblatexoptions: [backend=bibtex]

and the compilation end with WARNING: maximum number of runs (9) reached. Increasing latex-max-runs:99, does not solve the issue.

As there are no latex-max-runs in pandoc, I think this may be related to Quarto.

Similar behavior occurs when using YAML-encoded references (instead of an external bibliography) with either backend=bibtex or backend=biber. With cite-method: natbib only 3 runs are made, but still without bibliography in the pdf output. I assume that YAML-encoded references are, up to now, only supported for the cite-method: citeproc in Quarto. Perhaps a notice on the references page should point this out. Especially, biblatex and natbib are intended for use in producing a LaTeX file that can be processed with bibtex or biber, as mentioned in Pandoc documentation.

Steps to reproduce

Here a basic Quarto document (named example-bibtex.qmd):

---
title: "example backend=bibtex"
author: "D. Folio"
format: 
  pdf:
    cite-method: biblatex
    biblatexoptions: [backend=bibtex]
    latex-max-runs: 22

nocite: "[@*]"
bibliography: bibtex.bib # you may use any 
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

example of bibtex.bib

@software{Allaire_Quarto_2022,
  author = {Allaire, J.J. and Teague, Charles and Scheidegger, Carlos and Xie, Yihui and Dervieux, Christophe},
  doi = {10.5281/zenodo.5960048},
  month = jan,
  title = {{Quarto}},
  url = {https://github.com/quarto-dev/quarto-cli},
  version = {1.2},
  year = {2022}
}

or with YAML-encoded references

format: 
  pdf:
    cite-method: biblatex
    biblatexoptions: [backend=biber]   #<---------------- same behavior with either bibtex or biber
references:
- type: article-journal
  id: WatsonCrick1953
  author:
  - family: Watson
    given: J. D.
  - family: Crick
    given: F. H. C.
  issued:
    date-parts:
    - - 1953
      - 4
      - 25
  title: 'Molecular structure of nucleic acids: a structure for deoxyribose nucleic acid'
  title-short: Molecular structure of nucleic acids
  container-title: Nature
  volume: 171
  issue: 4356
  page: 737-738
  DOI: 10.1038/171737a0
  URL: https://www.nature.com/articles/171737a0

and run quarto render example-bibtex.qmd

Expected behavior

A similar behavior as with biblatexoptions: [backend=biber]

Rendering PDF
running xelatex - 1
[...]

generating bibliography
[...]

running xelatex - 2
[...]

running xelatex - 3
[...]

Output created: example-bibtex.pdf

Actual behavior

Rendering PDF
running xelatex - 1
[...]

running xelatex - 2
[...]

running xelatex - 3
[...]
running pdflatex - 10

WARNING: maximum number of runs (9) reached

Output created: example-bibtex.pdf

With YAML-encoded references , empty bibliography file are generated.

The references are not rendered in the example-bibtex.pdf.

Your environment

Quarto check output

quarto 1.4.429
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.8: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.4: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.429
      Path: /opt/quarto-1.4.429/bin

[✓] Checking tools....................OK
      TinyTeX: v2023.10
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /home/dfolio/.TinyTeX/bin/x86_64-linux
      Version: 2023

[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
      Version: 3.10.13
      Path: /usr/lib/python-exec/python3.10/python3
      Jupyter: 5.4.0
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /usr/lib64/R
      LibPaths:
        - /home/dfolio/R/x86_64-pc-linux-gnu-library/4.3
        - /usr/lib64/R/library
      knitr: 1.44
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK
dragonstyle commented 8 months ago

I'm not sure what the underlying cause of this issue, but I don't think this is a Quarto bug (at least not with the latexmk runner). Specifically, after each run, we are detecting that another compilation is required because of the following issue:

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please (re)run BibTeX on the file(s):
(biblatex)                test
(biblatex)                and rerun LaTeX afterwards.

You can use the option latex-clean: false to keep intermediate files around post compilation, which can be helpful when trying to figure out what is going on with the pdf compilation.

cderv commented 7 months ago

I assume that YAML-encoded references are, up to now, only supported for the cite-method: citeproc in Quarto.

This is only support by Pandoc's Citeproc as described in Pandoc's Manual (https://pandoc.org/MANUAL.html#specifying-bibliographic-data). If using --natbib or --biblatex, a bibliography file is needed.

With cite-method: natbib only 3 runs are made, but still without bibliography in the pdf output.

Regarding nocite field, I don't think Pandoc does handle it correctly right now. \nocite command should be added in body and not in header I believe. So if you add \nocite{*} in your document you should get the reference

---
title: "example backend=bibtex"
author: "D. Folio"
format: 
  pdf:
    cite-method: natbib
keep-tex: true
bibliography: bibtex.bib
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

\nocite{*}

I don't know a lot about [backend=bibtex], but I do believe the infinite loop here is due to the fact that \nocite{} is not handled, and that there is no reference found. This seems to be LaTeX issues and I am not sure how Quarto should handle this differently.