17

I am using biblatex for citations and bibliography. Now I often have lists of multiple citations, for which biblatex has the \cites command. Now I can get citations to automatically sort if I don't want page numbers, but I cannot get it right with page numbers.

What I want is all citation ordered chronological (oldest first). Is this possible, or must I just do this by hand?

Here is an example.

\documentclass[11pt,oneside]{memoir}

\usepackage[
    style=authortitle,
    useprefix=false,
    maxnames=2,
    firstinits=true,
    sortcites=true,
    uniquename=init,
    abbreviate=true,
    backend=biber,
    sorting=ynt
]{biblatex}

\begin{filecontents}{jobname.bib}
@book{tom1,
  author = {Author, A.},
  year = {2001},
  title = {This book is from 2001},
  shorttitle = {2001},
}
@book{tom2,
  author = {Author, A.},
  year = {1999},
  title = {This book is from 1999},
  shorttitle = {1999},
}
\end{filecontents}

\addbibresource{jobname.bib}


\begin{document}
This one is corrent.\footnote{\Cites{tom1,tom2}.}
This one is corrent.\footnote{\Cite{tom1,tom2}.}


This one is incorrent.\footnote{\Cites{tom1}{tom2}.}
This one is incorrent.\footnote{\Cites[1]{tom1}[12]{tom2}.}
\end{document}
2
  • 8
    Technically, the "incorrect" examples are correct as \Cites is a "multicite" command where each key is a stand-alone citation, not part of a list of citations. It's used precisely for manually ordering etc. You're right that there seems to be no cite ordering possible when you need to give pages for each key.
    – PLK
    Commented Aug 4, 2012 at 14:35
  • Yeah, I realise that they are technically correct. Just not exactly what I want... I was hoping there was a way to solve this. Commented Aug 5, 2012 at 9:42

1 Answer 1

12

Edited (2018-07-14) by moewe for biblatex >= v3.8. See the edit history for older biblatex versions.

The multicite commands take arbitrarily many arguments. They aren't designed to output a sorted citation list. It is possible to construct a two-pass version of \cites that will generate a sorted, qualified citation list.

\documentclass{article}
\usepackage[style=authortitle,sorting=ynt,sortcites]{biblatex}

\makeatletter

% original definition of \cites
\DeclareMultiCiteCommand{\cbx@cites}{\cite}{\multicitedelim}

% new definition
\DeclareMultiCiteCommand{\cites}[\cbx@cite@wrapper\cbx@cites]{\cbx@cite}{}

% first pass saves keys, prenotes, postnotes
\DeclareCiteCommand{\cbx@cite}
  {\csxdef{prenote:\thefield{entrykey}}{\thefield{prenote}}}
  {\listxadd\cbx@savekeys{\thefield{entrykey}}}
  {}
  {\csxdef{postnote:\thefield{entrykey}}{\thefield{postnote}}}

% second pass outputs sorted citation list
\newrobustcmd{\cbx@cite@wrapper}[2]{%
  \def\cbx@savekeys{}%
  \def\cbx@citecall{#1}%
  #2\cbx@sortkeysinit\cbx@citesort\cbx@citecall}

% internal list of saved keys => sorted argument list
\def\cbx@citesort{%
  \def\do##1{%
    \ifinlist{##1}{\cbx@savekeys}
      {\protected@xappto\cbx@citecall{%
         [\csuse{prenote:##1}][\csuse{postnote:##1}]{##1}}}
      {}}%
  \dolistloop{\cbx@sortkeys}}

% internal list of sorted entry keys
\def\cbx@sortkeysinit{%
  \ifcsundef{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
    {}
    {\global\csletcs{cbx@sortkeys}{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}}
\def\cbx@sortkeys{}

\makeatother

\addbibresource{biblatex-examples.bib}
\newcommand{\cmd}[1]{\texttt{\textbackslash #1}}
\setlength{\parindent}{0pt}
\begin{document}
\cmd{cite}: \cite{companion,ctan,vangennep,markey} \\
\cmd{cites}: \cites[e.g.][10]{companion}{ctan}{markey}[10--11]{vangennep} \\
\cmd{Cites}: \Cites{ctan}{markey}[e.g.][5--10]{companion}[10--11]{vangennep}
\printbibliography
\end{document}

enter image description here

Note that this new version of \cites does not properly support multiprenote and multipostnote arguments of the form

\cites(<pre>)(<post>)...

A tidy resolution will probably warrant extension of biblatex internals. This is something we should consider as \textcites in the verbose styles suffers from the same limitation.

8
  • Ah, thanks for that. I've actually subsequently gone back and edited every use of \cites in my PhD... Oh well. Commented Oct 4, 2012 at 14:21
  • 1
    What is the answer for this thread? I am getting stuck with this issue too. I want to cite two authors in a row but wanting to add their appropriate page numbers.
    – user24947
    Commented Jan 24, 2013 at 19:43
  • 1
    @expling I've given an answer above. If you don't want the citations printed in the same order as the bibliography, then refer to this post: tex.stackexchange.com/q/18910.
    – Audrey
    Commented Jan 26, 2013 at 17:37
  • With bibtex this works, but when using biber I get undefined control sequence \cbx@sortkeys.
    – user4514
    Commented Mar 5, 2014 at 17:00
  • @user4514 That error resolves after you run biber the first time. To avoid it entirely replace the biber-specific code with \ifcsundef{blx@slists@\the\c@refsection @entry@\blx@sorting}{}{\global\letcs{\cbx@sortkeys}{blx@slists@\the\c@refsection @entry@\blx@sorting}}.
    – Audrey
    Commented Mar 5, 2014 at 20:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .