Github did not allow me to post the full issue so I will do it in pieces.

Issue #1660 led me to look for a way to include uncited works in a book bibliography, which I am doing by including a text file with the relevant bibtex keys in the #refs div. (A seemingly equivalent approach is to cite those works in a .hidden div.) However, that led to a problem in which citations and the bibliography may not be properly synchronized.

I am not sure of precisely when the problem will occur, but here is a way to produce one circumstance in which it occurs:

- In RStudio, create a new book project.
- Add 2 more Knuth works to the references.bib file. Assume that, in addition to the May 1984 journal article included in the default book project, he had a two-volume technical report put out through ABC Institution called "More Literate Programming", where Volume 1 came out in June 1984 and Volume 2 came out in July 1984. Assume the bibliographic software (Zotero in my case) assigned bibtex keys knuth84b and knuth84a to Volumes 1 and 2 respectively. For my testing purposes I put Volume 2 into the file before Volume 1 but I don't know if that ordering is important. The references.bib file will now look like the code block that I will copy into a subsequent comment.
- Cite Volume 2 (knuth84a) in intro.qmd (in addition to the existing cite of the journal article), but do not cite Volume 1. The relevant line in intro.qmd will now be:

`See @knuth84 and @knuth84a for additional discussion of literate programming.`

- Put the bibtex keys for all 3 works (journal article and 2-volume technical report) in a separate text file, to help implement my workaround to allow a full bibliography in a book. (I would create this file programmatically by reading the references.bib file.) I call the file "all_cited_and_uncited_works.txt". It will look like this:
```
@knuth84
@knuth84a
@knuth84b
```
- Include the file in the references.qmd file, in the #refs div. Here's what my references.qmd file looks like:

```
# References {.unnumbered}

::: {#refs}
{{< include all_cited_and_uncited_works.txt >}}
:::

```
- Render the book. I do this via "quarto render" from the terminal.
- Look at intro.html. You should see the following for the citations

> See Knuth (1984b) and Knuth (1984a) for additional discussion of literate programming.

- Quarto has assigned 1984b to the journal article (1st citation) and 1984a to Volume 2 of the report. While this may seem surprising it is ok as far as I can tell - there's no reason it should have the same year-letter values as the bibtex keys, because quarto should assign them based on appearance in the bibliography, whereas Zotero or other bibliographic software will assign them considering all works by the same author in the particular citation library. Hovering over the hyperlinked 1984b and 1984a values in intro.html shows that they do, indeed, reference the article and Volume 2 report properly.

jjallaire
2022-08-04T11:38:24Z
donboyd5
closed
Citations not properly synchronized with bibliography in certain cases - v.2
https://github.com/quarto-dev/quarto-cli/issues/1678