[Tex/LaTex] BibTex (natbib) messing up citation order

natbib

I'm trying to use Natbib with squared numbers. However, in my text, the citations does not appear correctly. First when I tried it out, it numbered the citations correctly, so the first citation in the text would be named [ 1], and the second [2], and so forth. However, when I moved some text around, and the citations still kept their original numbers instead of automatically detecting which citation comes first.

To illustrate my problem:

Problems with citation order

Here's my MWE:

\documentclass[a4paper,11pt]{book} 
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[square,numbers]{natbib} 
\bibliographystyle{abbrvnat}

\begin{document}

This was once citation 2, but should be citatation 1, since it now appears first: \cite{pmid25348421}
This was once citation 1, but should be citation 2, since it currently appears second: \cite{pmid19995345}

\bibliography{Referencer}

\end{document}

I have tried to remove all the .aux files, and also scoured the internet for solutions, but all for naught.

Best Answer

The bibliography style you want is “unsorted”, that is, the bib items are listed in order of appearance. Thus you need

\bibliographystyle{unsrtnat}

rather than abbrvnat.

Remember to rerun BibTeX after doing the change.

Related Question