Skip to content

Fix BibTeX running for natbib documents without citations - #15380

Merged
cderv merged 3 commits into
mainfrom
fix/latexmk-runs-bibtex-when-aux-has-only-one-of-citation-bibdata-bibstyle-tinytex-requires-all-three
Nov 16, 2026
Merged

cderv merged 3 commits into
mainfrom
fix/latexmk-runs-bibtex-when-aux-has-only-one-of-citation-bibdata-bibstyle-tinytex-requires-all-three

Conversation

@cderv

@cderv cderv commented Nov 16, 2026

Copy link
Copy Markdown
Member

When a PDF document uses cite-method: natbib with a bibliography and a bibliography style but cites nothing, BibTeX still runs. It reports I found no \citation commands, and when the style file is not installed the render fails after the PDF was written. Templates that always set a style hit this with every document without citations, like quarto-journals/springer in #15376.

Root cause

Before running BibTeX, Quarto reads the .aux file written by LaTeX, which records the citations (\citation), the bibliography files (\bibdata) and the style (\bibstyle). The check passed when any one of the three was present (src/command/render/latexmk/pdf.ts:591). A document with a bibliography and a style but no citation only has \bibdata and \bibstyle, so BibTeX ran for nothing.

The same check in TinyTeX's latexmk() (require_bibtex()) requires all three, since rstudio/tinytex@732ca9b.

Fix

The check now requires \citation, \bibdata and \bibstyle, as TinyTeX does. A document using nocite: '@*' still runs BibTeX, as it writes \citation{*}. biblatex with biber is not affected, it does not use this check.

New smoke-all tests cover a document without citation (with a style that is not installed, so a BibTeX run would fail the render), a document with a citation, and a document with nocite.

The missing .bst auto-install and the Windows crash reported in #15376 are not addressed here.

Related to #15376

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone, TinyTeX source on GitHub
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

The latexmk emulation ran BibTeX for natbib whenever the .aux file had
any one of \citation, \bibdata or \bibstyle. The check was ported from
TinyTeX's require_bibtex(), which requires all three; the single
alternation regex turned that AND into an OR.

A document with no citation still gets \bibstyle and \bibdata in its
.aux file when a bibliography and a style are set, which is what
templates that always set a style do (quarto-journals/springer sets
sn-basic). BibTeX then runs, reports "I found no \citation commands",
and when the style is not installed the render fails after the PDF was
written.

The new smoke-all tests cover a document without citations (BibTeX
must not run, with a style that is not installed so a run would fail
the render), a document with a citation, and a document using
nocite: @*, which writes \citation{*} and must still run BibTeX.
@posit-snyk-bot

posit-snyk-bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv merged commit 1d80652 into main Nov 16, 2026
8 of 11 checks passed
@cderv
cderv deleted the fix/latexmk-runs-bibtex-when-aux-has-only-one-of-citation-bibdata-bibstyle-tinytex-requires-all-three branch November 16, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants