[Tex/LaTex] Natbib sorting and citation order by appearance

citingnatbib

I've started writing my thesis using LaTeX (as recommended by the school) and as a complete novice at it, I've been stuck trying to figure out how to change the citation by order of appearance.

I'm using the natbib package and a custom bibliography style that I found on the net, with my referencing going by the author-year (John et al., 2005) style as opposed to numeric [1,3]. I have done some searching but most of my results come up with people using the numeric system and being a complete beginner at this, I have yet to tinker around with something that works.

The citation I have currently looks like this:
(Frank et al., 2005; John et al., 2002; Matthew, 2008)

I would like to sort it by year or turn off sorting so it will show up in the order I type it in the document.

E.g.: (John et al., 2002; Frank et al., 2005; Matthew, 2008)

The citing and bibliography itself are perfect, I'm only concerned with the citation order being unsorted (or sorted by appearance in the document), as currently it is sorting everything alphabetically by name. So my question is, how would one achieve sorting the references in the citation by appearance (or turning off alphabetical sorting) using natbib and a customized bibliostyle? And if that is not possible, could someone point me in the right direction on obtaining a similar effect?

Thank you in advance for your time and help.

Best Answer

The unsrtnat style orders the bibliography by citation order. Similar to the example from LaTeX/BibTex not arranging citations by order of appearance:

enter image description here

\documentclass{article}
\usepackage[semicolon]{natbib}

\begin{filecontents}{\jobname.bib}
@book{foo,
 author = {Foo},
 year = {2002},
 title = {Title of Foo},
}
@book{bar,
 author = {Bar},
 year = {2005},
 title = {Title of Bar},
}
@book{baz,
 author = {Baz},
 year = {2008},
 title = {Title of Baz},
}
\end{filecontents}

\begin{document}
\section{The Beginning}
First we cite \citep{foo}.
Now we cite \citep{bar}.
Then we cite \citep{baz}.
Finally, we cite \citep{foo,bar,baz}.

\bibliographystyle{unsrtnat}
\bibliography{\jobname}
\end{document}
Related Question