typst / hayagriva

Rusty bibliography management.
Apache License 2.0
350 stars 55 forks source link

Multi-reference single-author label collision with alphanumeric citation style #230

Closed jctemp closed 1 month ago

jctemp commented 1 month ago

Description

Citing many papers in some work is unavoidable. Using the alphanumeric citation style causes the label of the corresponding reference to render identical. One cannot manually set the the suffix. Maybe one could query the number of references and perform a transformation based on the current context (but I don't know if this works).

The following has the Typst code and BibLaTex references. I also provided the comparison to LaTex behaviour as well as the used code to produce the output.

#set cite(style: "alphanumeric", form: "normal")

#lorem(10) @chenTransMorphTransformerUnsupervised2021. #lorem(23) @chenViTVNetVisionTransformer2021. #lorem(10)

#bibliography("ref.bib")
@article{chenTransMorphTransformerUnsupervised2021,
  title = {{{TransMorph}}: {{Transformer}} for Unsupervised Medical Image Registration},
  author = {Chen, Junyu and Frey, Eric C. and He, Yufan and Segars, William P. and Li, Ye and Du, Yong},
  date = {2021},
}

@article{chenViTVNetVisionTransformer2021,
  title = {{{ViT-V-Net}}: {{Vision Transformer}} for {{Unsupervised Volumetric Medical Image Registration}}},
  author = {Chen, Junyu and He, Yufan and Frey, Eric C. and Li, Ye and Du, Yong},
  date = {2021},
}

Current behaviour" image

Expected behaviour: image

\documentclass{article}
\usepackage[style=alphabetic, sorting=none]{biblatex}
\addbibresource{ref.bib}

\usepackage{lipsum}

\begin{document}

\lipsum[1][1] \cite{chenTransMorphTransformerUnsupervised2021}. 
\lipsum[2][1]
\cite{chenViTVNetVisionTransformer2021}. 
\lipsum[3][1]

\printbibliography

\end{document}

Reproduction URL

https://typst.app/project/pvnJ3lO4BBYM0iaqwshID2

Operating system

Web app, Linux

Typst version

PgBiel commented 1 month ago

This appears to be a problem with the default alphanumeric style we ship, which is pretty basic: https://github.com/typst/hayagriva/blob/a1a27dc6ac58ddde3b4deed3ab441619d9e2b25a/styles/alphanumeric.csl

An immediate workaround is to switch to the chicago-author-date style instead.

One way to fix it would be to add disambiguate-add-year-suffix="true" to <citation> in the style, and then allowing the year suffix to be applied by adding <text variable="year-suffix" prefix="-"/> to the citation <layout>. However, that doesn't seem to work unless a <date>, such as <date variable="issued" />, is used, then we get "a" and "b" in the labels (although not in the bibliography entries, where the suffix gets added to the dates, which seems to comply with the CSL spec). Not sure if that (requiring a <date> even when using a <text>) is intentional or not, but I could see how the year-suffix might be ambiguous without knowledge of which date's year to use, so I think that's spec-compliant.

In general, the problem here, I think, is that we're using the citation-label variable which doesn't work as a date, even though it (perhaps coincidentally) has a year. Some form of "global disambiguator" regardless of dates would be more useful here. Further investigation is needed to see if CSL has some avenue for this (I noticed that it allows checking for disambiguation in <choose>, but not sure if this allows adding your own suffixes that aren't year-suffix).

jctemp commented 1 month ago

An immediate workaround is to switch to the chicago-author-date style instead.

Not exactly as the used citation label changes from [Abbrv+Year] to (Author A, B et al. year). Morever, no links to the bibliography are provided if chicago-author-date is used.

One way to fix it would be to add disambiguate-add-year-suffix="true" to <citation> in the style

Maybe but one needs to disambiguate the labels on a level where author and year collide.

Some form of "global disambiguator" regardless of dates would be more useful here.

I agree. A collision is also possible with the workaround style if Author A, Author B and year match? Sadly, I don't know CLS defines the handling of these issues, e.g. appending a random suffix of length n to disambiguate all colliding references. A scholar had once the issue where he used up all suffixes and even BibLaTex errored. Maybe this insight is helpful to futher mitigate these extremes.