Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

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.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear,maxnames=2]{biblatex}

\renewcommand*{\finalnamedelim}{\addspace\&\space}

\addbibresource{biblatex-examples.bib}

\begin{document}
Filler text \parencite{bertram,companion,jaffe,moraux}.
\printbibliography
\end{document}

enter image description here

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 and

\renewcommand*{\finalnamedelim}{%
  \ifbibliography
    {\addspace\&\space}
    {\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
     \addspace\bibstring{and}\space}}

If 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 to editor, bookauthor, translator, etc. your name lists will appear inconsistent.

share|improve this answer
    
Thank you so much! –  Timothée Poisot Feb 10 '12 at 17:30
    
@TimothéePoisot No problem. lockstep provides a nice introduction to customizing biblatex styles in this post. Making minor changes to bibliography macros and drivers is easy with egreg's xpatch package. –  Audrey Feb 10 '12 at 17:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.