2

How to sort the in-text citations by year, but those of the bibliography by name?

\documentclass{MastersDoctoralThesis} % Online template
\usepackage[backend=bibtex,style=authoryear-comp, natbib=true, maxcitenames=1, url=false, doi=false, sorting=ynt]{biblatex}

\bibliography{mybib}

mybib is a bib file that contains:

@ARTICLE{neu1984,
   author = {{Neugebauer}, G. and {Habing}, H.~J. and {van Duinen}, R.},
     year = 1984}

@ARTICLE{kes1996,
   author = {{Kessler}, M.~F. and {Steinz}, J.~A. and {Anderegg}, M.~E.},
     year = 1996}

MWE:

\begin{document}
\citealt{neu1984,kes1996}
\printbibliography
\end{document}

The result is sorted chronologically in-text:

enter image description here

and in the bibliography, it appears sorted chronologically, but i would like it in alphabatical order:

enter image description here

1) I tried, as suggested in other solutions:

\begin{refcontext}[sorting=ny]
\printbibliography
\end{refcontext}

It says:

! LaTeX Error: Environment refcontext undefined.

2) I tried:

\printbibliography[sorting=ny]

It says:

! Package keyval Error: sorting undefined.

2

With a current version of biblatex the correct method is to use refcontexts, something similar to the method 1 you show in the question. But refcontexts only work with Biber as backend, you cannot use BibTeX.

So you need to switch to Biber. In theory that should be as easy as changing backend=bibtex, to backend=biber, and running – or instructing your editor to run – Biber instead of BibTeX (see Biblatex with Biber: Configuring my editor to avoid undefined citations). (If you having trouble running Biber, have a look at Troubleshooting for biber for first aid. Feel free to ask a new question if you continue having trouble getting Biber to run even after going through that post. Please post the .blg file in that case.)

Then it should be enough to give the desired citation sorting sorting=ynt, as global option and wrap \printbibliography in a new refcontext with sorting=nyt.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber,
  style=authoryear-comp,
  sorting=ynt,
  maxcitenames=1,
  natbib=true,
  url=false, doi=false,
]{biblatex}

\begin{filecontents}[force]{\jobname.bib}
@ARTICLE{neu1984,
  author = {Neugebauer, G. and Habing, H. J. and van Duinen, R.},
  year   = 1984,
}
@ARTICLE{kes1996,
  author = {Kessler, M. F. and Steinz, J. A. and Anderegg, M. E.},
  year   = 1996,
}
\end{filecontents}
\addbibresource{\jobname.bib}


\begin{document}
\autocite{kes1996,neu1984}

\begin{refcontext}[sorting=nyt]
\printbibliography
\end{refcontext}
\end{document}

(Neugebauer et al., 1984; Kessler et al., 1996)//Kessler, M. F., J. A. Steinz and M. E. Anderegg (1996). In://Neugebauer, G., H. J. Habing and R. van Duinen (1984). In:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.