`alphanumeric` style: How to get disambiguation letters (e.g., [ASS96a] and [ASS96b]) in bibliography labels?

When using the alphanumeric citation style, I’ve encountered an issue with how bibliography labels are generated when there are multiple entries by the same author(s) in the same year.

Typst disambiguates the citations in the text by adding letters (e.g., a, b), as expected, but it doesn’t seem to apply the same disambiguation to the labels within the bibliography itself. Both entries end up with the same label (e.g., [ASS96]).

Here’s a minimal example:

#set cite(style: "alphanumeric")

@Abelson1 @Abelson2

#bibliography(
    bytes("
@book{Abelson1,
  title     = {Structure and Interpretation of Computer Programs},
  author    = {Harold Abelson and Gerald Jay Sussman and Julie Sussman},
  year      = {1996}
}
@book{Abelson2,
  title     = {Computers},
  author    = {Harold Abelson and Gerald Jay Sussman and Julie Sussman},
  year      = {1996}
}
"),
)

This produces the following output:

The text citation shows [ASS96a, ASS96b], as expected. However, in the Bibliography section, both entries are labelled [ASS96] and the year within the entry details gets the letter, like 1996a, but the main bracketed label remains ambiguous.

For comparison, here is how biblatex (with style=alphabetic) handles the same situation in LaTeX:

\begin{filecontents}{refs.bib}
@book{Abelson1,
  title     = {Structure and Interpretation of Computer Programs},
  author    = {Harold Abelson and Gerald Jay Sussman and Julie Sussman},
  year      = {1996}
}
@book{Abelson2,
  title     = {Computers},
  author    = {Harold Abelson and Gerald Jay Sussman and Julie Sussman},
  year      = {1996}
}
\end{filecontents}

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

\begin{document}
~\cite{Abelson1, Abelson2}

\printbibliography
\end{document}

This LaTeX code produces the following output:

Here, the bibliography labels themselves are disambiguated as [ASS96a] and [ASS96b].

Is there a way in Typst, to make the bibliography labels include the disambiguation letters to match the text citations and the behavior shown in the LaTeX example?

Any help or pointers on how to achieve this would be greatly appreciated!

Thanks!

1 Like

Hello, this is a duplicate of Why is "Alphanumeric" not suitable for bibliographies?.

Thanks for the quick reply. As far as I understand it, the built-in alphanumeric style only defines the <citation> part in CSL terms and lacks specific <bibliography> formatting instructions.

However, to my understanding, the citation-label is generated by the processor, and I would expect it to be consistent across both the in-text citations and the bibliography entries.

What also seems odd to me is that setting cite(style: "alphanumeric") does appear to influence the bibliography rendering in some way. For example, as noted in my original post, the year within the bibliography entry’s text gets the disambiguation letter appended (e.g., showing 1996a in the details). If alphanumeric is strictly a citation style, I would not expect this to modify the content of the bibliography entry itself.

My main goal isn’t to delve too deeply into the implementation details, but rather to find a practical solution for the visual output. So, my fundamental question remains:

Is there a way within Typst (perhaps by using some functions, possibly in conjunction with a custom CSL file) to ensure that the citation-label displayed in the bibliography list itself includes the disambiguation letter (i.e., shows [ASS96a], [ASS96b]) to consistently match the in-text citations, similar to the LaTeX/biblatex example?

You can find a different style in GitHub - citation-style-language/styles: Official repository for Citation Style Language (CSL) citation styles., there are about half of them that use disambiguate-add-year-suffix. Some of them are included in Typst.

I tested several styles from the repository that use the disambiguate-add-year-suffix="true" option.
Unfortunately, I seem to be encountering the exact same behavior with all the styles I’ve tried:

  1. The in-text citations are correctly disambiguated with the letter suffix (e.g., [ASS96a]).
  2. The bibliography entry text shows the year with the suffix (e.g., ... 1996a.)`.
  3. However, the bibliography label itself (the part in brackets at the start of the entry), consistently lacks the suffix (e.g., it still shows [ASS96]).

There is an open issue #255. I haven’t looked into it, but this probably can’t by solved by CSL styles.

Thank you for pointing to the issue. I had missed that one. That seems to describe the behavior I’m seeing.

I’ll keep an eye on that issue. In the meantime, I’ll leave this question unsolved in case someone has perhaps found a clever workaround using the scripting capabilities to achieve the desired output.

The reason for this is that the suffix isn’t part of the citation-label. You can notice that the <citation> for this style has two important components (besides the optional supplement / locator): the citation-label and year-suffix.

If your bibliography style does not add year-suffix explicitly, it does not get rendered. It seems that your style chose to add it at the end of the entry in this case, which is why the letter appears there.

There is more info, including a workaround, in this post: Why does Hayagriva with this .csl file not produce year disambiguation?

(I think we should eventually merge those threads to keep it clean…)

I’m not sure if we can consider this a deficiency in the CSL spec or a hayagriva bug, but it is worth an investigation. Unfortunately, I haven’t found much info on how other processors handle this yet, but I’d appreciate further contributions here.

OP of the referenced forum post here:

and it should be noted that, depending on what one is looking for, only partial solutions currently exist for year disambiguation. In particular, the only approach that ensures bibliography entries have year disambiguation also breaks the formatting, in that the line wrapping in the bibliography proceeds to have new lines flushed left with the labels (e.g. [ASS96b]), rather than having the entries treated separately.

Thanks for linking this. I agree with you that my post is basically a duplicate of that question.

Playing around with it already, I also noticed the same problem. I don’t know the specifics about the actual implementation or intended behavior, but what I gathered is that when using second-field-align="flush", Typst seems to create a grid where the first element goes in the first column and the remaining elements go in the second column. Consequently, just adding the year-suffix after the label in the bibliography definition causes the label to be in the first column and the year disambiguation in the second column, instead of them “sticking” together. Sadly, wrapping both in a CSL <group> does not seem to count as a single “element” in this case and still splits them up.

Removing second-field-align="flush" could visually work around this specific problem by keeping the suffix next to the label. However, I agree with you that this is not a proper fix, as it breaks the overall alignment of the bibliography entries and therefore does not result in the intended output I’ve shown in the LaTeX example.

That seems to be incorrect. Instead, it appears the citation-label specifically gets placed in the first column, even if it isn’t the first element defined in the layout.

In my personal opinion, the current behavior should perhaps not be the default one. But I don’t know enough about Hayagriva or CSL to say if it currently is the expected behavior or not.
With the current way it’s handled, I was hoping for a workaround. The idea would be similar to the workaround mentioned in the other thread, where the CSL is modified so the label with the year disambiguation gets added to the “main content” of the bibliography entry (without using second-field-align). Then, later in Typst, using tools like regex, selectors, and other functions, one could potentially build a custom grid structure that looks like the desired output. However, my knowledge of Typst is not currently sufficient to implement this myself.