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.

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}
\addbibresource{\jobname.bib}
\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:

Alice, Bob, Charlie vs. Alice, Bob and Charlie

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?

share|improve this question
    
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
2  
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
add comment

1 Answer 1

up vote 5 down vote accepted

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}}%
     \addspace\bibopenbracket}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \savefield{namehash}{\cbx@lasthash}%
  \ifnumequal{\value{citecount}}{\value{citetotal}-1}
    {\gdef\cbx@tempa{\bibclosebracket\addspace\bibstring{and}\addspace}}%
    {\gdef\cbx@tempa{\bibclosebracket\multicitedelim}}%
}  
\makeatother

It produces:

enter image description here

share|improve this answer
    
Great, works perfectly, even for contracted entries due to duplicate authors :) –  Christian Jan 7 '13 at 9:41
    
Any suggestions for natbib + bibtex? –  Mario S. E. May 2 '13 at 18:19
1  
@Christian Not quite perfectly; the final delimiter is incorrect when the last two (or more) citation labels are compressed. To fix this just upgrade to biblatex 2.7. –  Audrey Jul 13 '13 at 16:39
    
@Audrey Great to see this in biblatex now :) Just did an upgrade. –  Christian Jul 13 '13 at 21:03
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.