I want to sort in-text citations by year, but bibliography by name. It sound exactly like this question.
However, suggested solution (using \usepackage[sorting=ynt]{biblatex}
and \printbibliography[sorting=nty]
) does not work for me (see MWEB below). Indeed, the list of references remains year-sorted instead of name sorted.
Question: How to force sorting=nty
in \printbibliography
?
\documentclass{article}
\usepackage[%
backend=biber,%
style=authoryear-comp,%
natbib=true,%
sorting=ynt%
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{key2000,
author = {Author, A.},
year = {2000},
title = {Alphabetical fist \& Year last},
publisher = {Publisher},
}
@book{key1900,
author = {Boathor, B.},
year = {1900},
title = {Alphabetical last \& Year first},
publisher = {Publisher},
}
\end{filecontents}
\begin{document}
Citation should be year-sorted, even if \verb+\citep+ is random \citep{key2000, key1900}.% citation NOT year-sorted
\printbibliography[sorting=nyt]
\end{document}
P.S.: At the opposite, using
\begingroup
\newrefcontext[sorting=nyt]
\printbibliography
\endgroup
overrides the \usepackage[sorting=ynt]{biblatex}
option (i.e. LoR is name-sorted, but in-line citations as well).
sorting
option has been moved from\printbibliography
to so called 'refcontexts'. See Biblatex order of entries in a multi-citation. And the default is that all citations obey the refcontext they were last printed in the bibliography. So simply using a globalsorting
that contradicts the\printbibliography
'srefcontext
'ssorting
does not worksortcites=false
and manually sorting references within citation... but I wanted to be lazy and make (Bib)LaTeX do it for me! | Just to be sure to understand your previous comment: the sorting scheme chosen, is the one of therefcontext
selected whenprintbibliography
is called and not at the time of the\cite
command, right? (I tried to add\newrefcontext[sorting=ynt]
right after\begin{document}
+ what I added in my P.S, but it indeed doesn't work.)\printbibliography
. There are ways to manually assign the refcontext (i.e. override the 'use the refcontext of the last bibliography' rule). But you need to be careful about potentially different extrayears.