Special format for label made from author initials

biblatex with style=alphabetic generates a label from the author name(s) in a way depending on the number of authors: (1) for a single author or “many” authors, the label is made from the beginning of the first author's last name; (2) for ”few” authors, it is made from all authors' initials.

I would like to apply a format only for case (2). Specifically, I wanted to set the label in small caps.

The following code does what I said, but it also sets type (1) labels in small caps, so it is not really a solution.

\documentclass{article}

\begin{filecontents*}{\jobname.bib}
@document{one,
author = { Single Author },
}
@document{few,
author = { One and Two and Three Authors },
}
@document{many,
author = { One and Two and Three and Four Authors },
}
\end{filecontents*}

\usepackage[style=alphabetic,]{biblatex}

%---//
\DeclareLabelalphaTemplate{
\labelelement{
\field[final]{shorthand}
\field{label}
\field[strwidth=3,strside=left,ifnames=1]{labelname}
\field[lowercase,strwidth=1,strside=left]{labelname}
}
\labelelement{
\field[strwidth=2,strside=right]{year}
}
}

\DeclareFieldFormat{labelalpha}{\textsc{#1}}
%---\\

\begin{document}

\cite{one,few,many}

\printbibliography
\end{document}


For reference, here's the output from the MWE compared to the default aplphabetic style:

It seems that adding conditional formatting to the label during \DeclareLabelalphaTemplate is not really feasible. In your case, however, that is not really necessary, it is enough to apply the formatting afterwards (this might not work in all possible use cases, but it does here).

In order to apply the correct format we first need to find out when to set the label in small caps; this is the case exactly if there is more than one author (a single author will have parts of their name written out, but not in small caps) and no more than three authors (for four or more authors, we get the first + et al.), so the following logic should do the trick:

\DeclareFieldFormat{labelalpha}{%
\ifboolexpr{
test {\ifnumgreater{\value{labelname}}{1}}
and not
test  {\ifnumgreater{\value{labelname}}{3}}
}
{\textsc{#1}}
{#1}}


MWE

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@document{one,
author = {Silvia T. Udent},
title = {Single Author},
year = {2001},
}
@document{two,
author = {William Riter and Anne Uthor},
title = {Two Authors},
year = {2002},
}
@document{three,
author = {Patricia Rofessor and Ronald E. Searcher and Silvia T. Udent},
title = {Three Authors},
year = {2003},
}
@document{four,
author = {William Riter and Anne Uthor and Patricia Rofessor and Ronald E. Searcher},
title = {Four Authors},
subtitle = {That Is: Many Authors},
year = {2004},
}
\end{filecontents*}
\usepackage[style=alphabetic]{biblatex}

\DeclareLabelalphaTemplate{
\labelelement{
\field[final]{shorthand}
\field{label}
\field[strwidth=3,strside=left,ifnames=1]{labelname}
\field[lowercase,strwidth=1,strside=left]{labelname}
}
\labelelement{
\field[strwidth=2,strside=right]{year}
}
}

\DeclareFieldFormat{labelalpha}{%
\ifboolexpr{
test {\ifnumgreater{\value{labelname}}{1}}
and not
test  {\ifnumgreater{\value{labelname}}{3}}
}
{\textsc{#1}}
{#1}}

\begin{document}
\nocite{*}

\printbibliography
\end{document}


• Your answer would deserve an extra upvote for the faux author names [though at least where I'm from, an author order of “S.T. Udent, R.E. Searcher, P. Rofessor” would be more usual :-)]. Also, let me note that while I do not like the result with Computer Modern very much, with my font choice (\usepackage[osf]{mathpazo}), it looks pretty good. Thanks! Oct 30 '14 at 11:47