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 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}
share|improve this question
6  
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 Aug 4 '12 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. –  Tom de Bruin Aug 5 '12 at 9:42
add comment

1 Answer 1

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@sort@\the\c@refsection}
    {\global\letcs{\cbx@sortkeys}
       {blx@slists@\the\c@refsection @entry@\blx@sorting}}% Biber
    {\global\letcs{\cbx@sortkeys}{blx@sort@\the\c@refsection}}}% BibTeX
\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.

share|improve this answer
    
Ah, thanks for that. I've actually subsequently gone back and edited every use of \cites in my PhD... Oh well. –  Tom de Bruin Oct 4 '12 at 14:21
    
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 Jan 24 '13 at 19:43
    
@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 Jan 26 '13 at 17:37
    
With bibtex this works, but when using biber I get undefined control sequence \cbx@sortkeys. –  user4514 Mar 5 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 Mar 5 at 20:12
show 1 more 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.