# Duplication of citation labels in amsrefs with shortalphabetic option

I'm having a problem with the citation labels automatically produced by amsrefs package when used with shortalphabetic option. Suppose that I have two authors with the same last name initial, say Aaa and Abc:

\documentclass{article}
\usepackage[shortalphabetic]{amsrefs}
\begin{document}
\begin{biblist}
\bib{a}{article}{
author={Aaa}
}
\bib{b}{article}{
author={Abc}
}
\end{biblist}
\end{document}


This correctly produces labels [A1] and [A2]. However, a problem occurs when author Aaa has another article with coauthor Bbb:

\documentclass{article}
\usepackage[shortalphabetic]{amsrefs}
\begin{document}
\begin{biblist}
\bib{a}{article}{
author={Aaa}
}
\bib{c}{article}{
author={Aaa},
author={Bbb}
}
\bib{b}{article}{
author={Abc}
}
\end{biblist}
\end{document}


The labels produced are [A], [AB], [A].

This seems like a bug. Am I doing something wrong? If it is a bug, is there a way to manually specify the citation label?

(The amsrefs package I'm using was packaged on 2010-08-30 according to MiKTeX package manager, is there a newer version?)

-
There exists an updated version 2012/05/08 v2.10, but the problem still exists. –  Werner Oct 15 '12 at 5:25
alerted to the problem by @DavidCarlisle (whose fingers apparently work faster than his brain, as he misspelled my name), i have turned the report over to the developer. –  barbara beeton Oct 15 '12 at 13:01

i've received a response from the developer. the way the assignment of labels works is by design. (however, the documentation is totally inadequate, and i've asked for it to be upgraded.)

replacing the citation label is possible. here's the relevant bit from the manual:

label: When the alphabetic or shortalphabetic options are used, amsrefs will usually try to generate the label on its own. If necessary, you can override the automatically generated label by specifying a label field.

here's the rationale given by the developer:

[...] if an author insists that the references appear strictly alphabetically by author name in the bibliography, he or she should use a citation style that's consistent with that ordering. An author who sees a reference to "L1", "LS" and "L2" is entitled to expect that the reference L2 appears before "LS", regardless of what the author names are just as an author who sees a reference to [1], [2] and [3] is entitled to expect that reference [2] appears before reference [3].

that said, i've seen a lot of bibliographies that ignore (or are unaware of) this principle. since many people don't read documentation, i'm not sure that stating it explicitly in the amsrefs manual would do much good. but at least a cross-reference from shortauthor to label would be useful.

update: the developer accepts the concept of a warning about duplicate labels as a reasonable request, and will look at it later, but can't promise a definite time to do so.

-
Thank you very much, I overlooked this option in the documentation. I quite agree with the developer's rationale, but I think amsrefs should at least produce a warning that duplicate labels are produced. –  Norbert P. Oct 16 '12 at 0:16

looks like a bug you should probably report it but we could try pinging @barbrarabeeton

This version patches amsrefs with additional checks, note it only patches the code path used for the shortalphabetic option. (My initial answer tried to include an updated package file that would cover more options but that was too big for this site)

It's not a complete fix but it makes it compare two labels back not just the preceding label for conflicts, so it works in this case.

\documentclass{article}
\usepackage[shortalphabetic]{amsrefs}

\makeatletter
\let\pprevious@stem\@empty

\def\fooo#1#2\global\let\previous@stem\current@stem#3\zz{%
\def#1{#2%
\global\let\pprevious@stem\previous@stem
\global\let\previous@stem\current@stem
#3}}

\def\foo#1{\expandafter\fooo\expandafter#1#1\zz}

\foo\generate@alphalabel

\let\generate@label\generate@alphalabel

\def\calc@alpha@suffix{%
\@tempswafalse
\compare@stems\previous@stem\current@stem
\ifsame@stems
\ifx\previous@year\current@year
\@tempswatrue
\fi
\else
\compare@stems\pprevious@stem\current@stem
\ifsame@stems
\ifx\previous@year\current@year
\@tempswatrue
\fi
\fi
\fi
\if@tempswa
\edef\alpha@label@suffix{\@suffix@format\alpha@suffix}%
\ifnum\alpha@suffix=\tw@
\immediate\write\@auxout{%
\string\ModifyBibLabel{\prev@citekey}%
}%
\fi
\else
\let\alpha@label@suffix\@empty
\global\alpha@suffix\@ne
\@xp\ifx \csname b@\current@citekey @suffix\endcsname \relax
\else
\edef\alpha@label@suffix{\@suffix@format\alpha@suffix}%
\fi
\fi
}

\makeatother

\tracingmacros3

\begin{document}
\begin{biblist}
\bib{a}{article}{
author={Aaa}
}
\bib{c}{article}{
author={Aaa},
author={Bbb}
}
\bib{b}{article}{
author={Abc}
}
\end{biblist}
\end{document}

-