# How to get an “and” before the last element in BibLaTeX's textcite commands?

When using \textcite or \textcites with more than one author in BibLaTeX, the result is not really usable and has to be fixed manually which can hardly be the point of the command:

\documentclass{minimal}
\listfiles
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{alice,
author = {Alice, A.},
}
@book{bob,
author = {Bob, B.},
}
@collection{charlie,
editor = {Charlie, C.},
}
\end{filecontents}
\usepackage[style=numeric,sortcites]{biblatex}
\begin{document}
Refer to the works of \textcite{charlie,alice,bob}.

Refer to the works of \textcite{alice,bob} and \textcite{charlie}.
\end{document}


Which looks like this:

One can argue about having a comma between the second and third element but surely the "and" is mandatory in English. So is there a way to get BibLaTeX to behave that way?

-
For the comma issue, have a look at the \finalandcomma macro in the biblatex manual which is especially for this. –  PLK Jan 7 '13 at 6:43
@PLK the manual states that this is for \finalnamedelim which sounds good but is just used for multiple names in one citation and not for multiple citations. Irritatingly so, I should add. –  Christian Jan 7 '13 at 9:44
Good point. We will look at this for biblatex 2.6 I think since 2.5 is likely to be released this month. –  PLK Jan 7 '13 at 19:37
@PLK that's great to hear :) –  Christian Jan 8 '13 at 9:48

Biblatex offers the counters citecount and citetotal. citetotal holds the total number of valid entry keys passed to the citation command, and citecount is the counter of the citation being processed. Thus we can use such counter to identify whether a citation is the last on in a list of citations. The standard definition of \textcite makes use of the macro textcite where the delimiter is inserted after the current entry. We can thus include a check to identify whether we are processing the second last entry, and to print an "and" instead of the delimiter.

Here is the modified version of the textcite biblatex macro

\makeatletter
\newbibmacro*{textcite}{%
\iffieldequals{namehash}{\cbx@lasthash}
{\multicitedelim}
{\cbx@tempa
\ifnameundef{labelname}
{\printfield[citetitle]{labeltitle}}
{\printnames{labelname}}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite}%
\savefield{namehash}{\cbx@lasthash}%
\ifnumequal{\value{citecount}}{\value{citetotal}-1}

@Audrey Great to see this in biblatex now :) Just did an upgrade. –  Christian Jul 13 '13 at 21:03