December 16, 2011

LaTeX Custom Bibliography Sorting

I'm currently writing a specialized paper to gain a bachelor's degree in Computer Science. The most painful part of writing was to sort the references which are stored in a bibliography using LaTeX.

I don't know whether I made a mistake or the sort styles just don't support ordering by the author's first name. Nevertheless here is a solution if you step into problems when sorting your references doesn't work like you'd expect :-)

First turn off sorting in your main .tex file
\bibliographystyle{unsrt}

When applying this, LaTeX will sort your references by its usage. So the reference used first, will be listed first. You turn this into an advantage. Now within your document, before you use any references in your paper, use this line for hidden text to apply your custom sorting.
\phantom
{
\cite{FirstRef}
\cite{SecondRef}
\cite{ThirdRef}
...
}

The only disadvantage you have to be aware of is that from now on you have to take care which references are really used in your paper to not reference anything unused.

Anyway this solution works good for me - if you know any better solution to this problem, please don't hesitate to write a comment :)

1 comment: