0

I'm using numerical citations. In LaTeX (in fact preferentially in LyX), would like to have a multiple-reference citation be sorted by year of publication [1,2,3]. That is, 3 was published after 2 and 1.

And later in the document if I cite [8,3,24] it should be that 24 was published after 3 and 3 after 8.

However, in the bibliography, I would like these numeric items to be sorted of course by number 1, 2, 3...

There are many questions with similar combinations, but I cannot find this one.

Here's my attempt, using biber

    \documentclass[]{article}

\begin{filecontents*}{references.bib} @misc{first, title={Reference A}, author={Alice}, year={1980}, }

@misc{second, title={Reference B}, author={Bob}, year={2000}, }

@misc{third, title={Reference C}, author={Caleb}, year={1970}, } \end{filecontents*}

\usepackage[ sortcites=ynt, sorting=none, backend=biber, hyperref=true, firstinits=true, maxbibnames=99, ]{biblatex}

\addbibresource{references.bib} \begin{document}

First: \cite{third,first,second} Second: \cite{second,first}

\printbibliography

\end{document}

The second citation should be 2,3, since Ref A was published earlier.

enter image description here

CPBL
  • 758

1 Answers1

0

In order to have full control over the sorting of separate \cite calls, you may want to define a new sorting scheme that takes into account citation order and publication date.

\documentclass[]{article}

\usepackage[ backend=biber, sortcites=true, sorting=noney, giveninits=true, maxbibnames=99, ]{biblatex}

\DeclareSortingTemplate{noney}{ \sort{\citeorder} \sort{ \field{sortyear} \field{year} } \sort{\intciteorder} }

\begin{filecontents}{\jobname.bib} @misc{first, title={Reference A}, author={Alice}, year={1980}, } @misc{second, title={Reference B}, author={Bob}, year={2000}, } @misc{third, title={Reference C}, author={Caleb}, year={1970}, } \end{filecontents} \addbibresource{\jobname.bib}

\begin{document} First: \cite{third,second,first} Second: \cite{second,first}

\printbibliography \end{document}

First: [1, 2, 3] Second: [2, 3]
[1] Caleb. Reference C. 1970.
[2] Alice. Reference A. 1980.
[3] Bob. Reference B. 2000.

Note that the sortcites option expects a boolean value (but any non-true value is treated as false). So sortcites=ynt, is treated as sortcites=false,.


\inciteorder was added in biblatex v3.18 (2022-06-22) and will therefore be available on all up-to-date TeX systems. If you cannot update, you can try to remove the line \sort{\intciteorder} from the definition of \DeclareSortingTemplate{noney} above. (This appears to work in the MWE with biblatex v3.16 from Overleaf's TeX Live 2021. But it may not work as intended in older systems, since there were changes to Biber's handling of sorting=none, not too long ago https://github.com/plk/biber/issues/404.)

moewe
  • 175,683
  • Doesn't compile for me. I get a "Undefined control sequence. \intciteorder" from pdflatex. (Also not entirely sure how to enter the declaration in LyX, but will stop trying that until it works in latex) – CPBL Oct 10 '22 at 16:47
  • @CPBL \intciteorder was added fairly recently. Make sure your system is fully up to date (https://tex.stackexchange.com/q/55437/35864). – moewe Oct 10 '22 at 19:44
  • Thanks. I have TeX Live 2022/dev/Debian) which is pretty recent! I'd rather not mess with my apt-administrated installation since it hasn't let me down so far. Are you saying this feature is from the last few months? It looks like it may be in biblatex v3.18 which is from July 2022. It might be worth giving this context in your answer, since most people are unlikely to have \intciteorder now. – CPBL Oct 12 '22 at 19:47