I have been working on a custom biblatex style, for which I want the bibliography to display at most 2 authors, meaning that the entries should be either:
- First (single author)
- First & Second (two authors)
- First et al. (three and more)
I came up with the following name format, to which I feed the first three authors using \printnames[][1-3]{author}\space
in the \DeclareBibliographyDriver
commands.
%%%% authors
\DeclareNameFormat{author}{%
\ifthenelse{\value{listcount}=1}%
{#1 \ifblank{#4}{}{\addcomma\space #4}}%
{%
\ifthenelse{\value{liststop}=2}%
{\space\&\space\ifblank{#4}{}{#4\space}#1}%
{%
\ifthenelse{\value{listcount}=3}%
{\space}%
{, et~al.}%
}%
}%
}%
It's working just fine, but given that I intend to move to biblatex, I'd like to have a very clean code, so the question is basically: how can it be improved?
Best Answer
What about name lists for editors or translators? If you want to apply the same truncation throughout, just use the package option
maxnames=2
. The rest is achieved by redefining\finalnamedelim
- a macro that sets the delimiter before the final item in a name list.The above sample document applies the format in both citations and the bibliography. To limit it only to the bibliography, use the option
maxbibnames=2
andIf you're really determined to define your own style, I'd use the generic name formats from
biblatex.def
as a starting point. Your format deviates from these in terms of name delimiters (\bibnamedelim...
), name part format (\mkbibname...
, casing, initials, order, etc.), elimination of spurious whitespace (\addspace
) and localization (\bibstring{andothers}
). Unless you apply similar formats toeditor
,bookauthor
,translator
, etc. your name lists will appear inconsistent.