# Citations in order of appearance

I am currently writing my thesis and using the class file provided by my university. Everything is fine and compiles well except for the citations and references.

The default setting is order the references alphabetically, but I want them ordered numerically....that is in the order in which I cited the references.

I have tried using

\usepackage[super,sort&compress]{natbib}


and then

\begin{document}
\bibliographystyle{unsrtnat}
\bibfiles{chap1,chap2,chap3,chap4,chap5}
\bibpunct{[}{]}{,}{s}{}{}


It does not work....I can see it modifying my references in some way. The first citation is [1] and then [2], but the third citation is [39]!

I also tried biblatex.

\pdfoptionpdfminorversion=6
\documentclass[12pt,hyperref]{gatech-thesis}
\usepackage{amsmath,amssymb,latexsym,float,epsfig,subfigure,textcomp}
\usepackage[style=numeric-comp]{biblatex}
\bibliography{chap1,chap2,chap3,chap4,chap5,chap6}
\usepackage[]{hyperref}

\begin{document}
\printbibliography


This one gives me a Latex error "Can only be used in preamble"....I tried reordering the location of the \usepackage[style=numeric-comp]{biblatex} command, but I still cannot get it to work.

But I did notice that a test file that I created to check biblatex (below) runs perfectly without any issues.

\documentclass{article}
\usepackage[style=numeric-comp]{biblatex}
\bibliography{examples}
\begin{document}
\nocite{*}
\printbibliography
\end{document}


So, I am not sure I understand why it won't work with the original class file. I would appreciate your help.

I think this is further complicated by the fact that I have citations within Figure captions.

\caption{blah blah...\cite{xyz}}

This might also be responsible for the problem.

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). There's also no need to 'sign' your post: your name is automatically added. –  Joseph Wright Oct 15 '11 at 15:52
Thanks Joseph, I am new to this forum so thanks for pointing that out. –  Avi Oct 15 '11 at 15:58
The gatech-thesis class redefines the bibliography commands and is therefore not compatible with biblatex without a good amount of modification. When you used natbib, did you make sure to run latex at least twice after running bibtex? –  Alan Munn Oct 15 '11 at 16:05
@Alan: As my MWE seems to work, could you give some details with regard to the imcompatibility? –  lockstep Oct 15 '11 at 16:13
Alan..I don't run Bibtex separately. I run Latex to PDF....in fact my editor (TexNiccenter) has the "run Bibtex" option grayed out.....sorry but I only have a basic knowledge of latex.. –  Avi Oct 15 '11 at 16:21

The following minimal example compiles correctly and produces the right reference number ordering. (Numbers begin at 1 and bibliography is in citation order rather than alphabetical.) If this works properly for you, then there is some other interaction with your document which will need some detective work to find out. If you have switched between biblatex and natbib in the course of figuring this out, make sure you delete all auxiliary files associated to your thesis and then try again.

\documentclass[hyperref]{gatech-thesis}
\usepackage[super,sort&compress]{natbib}
\usepackage{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@incollection{Baauw2001,
Author = {Sergio Baauw},
Booktitle = {Proceedings of the 25th Annual Boston University Conference on Language Development},
Editor = {A. H.-J. Do and L. Dom{\'\i}nguez and A. Johansen},
Pages = {82-93},
Title = {Expletive determiners in child Dutch and Spanish},
Year = {2001}}

@article{barker1998,
Author = {Chris Barker},
Journal = {Natural Language \& Linguistic Theory},
Pages = {679-717},
Title = {Partitives, Double Genitives and Anti-Uniqueness},
Volume = {16},
Year = {1998}}

@book{Berwick1985,
Author = {Berwick, Robert C.},
Publisher = {MIT Press},
Title = {Acquisition of syntactic knowledge},
Year = {1985}}

@phdthesis{Carlson1977,
Author = {Carlson, Gregory N.},
School = {University of Massachusetts, Amherst},
Title = {Reference to Kinds in {E}nglish},
Year = {1977}}

\end{filecontents}

\begin{document}
\bibpunct{[}{]}{,}{s}{}{}
\bibfiles{\jobname}

\bibliographystyle{unsrtnat}

\chapter{A chapter}
Some text.\cite{Carlson1977} Some text  \cite{Berwick1985} Some text \cite{Barker1998,Baauw2001}
\references
\end{document}


The gatech-thesis class is not designed to work with biblatex, and redefines the bibliography command to conform with the formatting requirements of your school. Although it might be possible to make it work with biblatex it would require quite a bit of modification.

-
Alan....thanks a ton. Your MWE seems to be working for me. But there might be a bug either in my references or some clash between the class file and natbib, because when I include ALL citations, it reverts back to the crazy ordering.However, currently I have commented out a large chunk of my thesis such that there are only 5 citations and that works like a charm...will give you an update soon. Also....is there a way I can input the references instead of having them all like above? It will clutter my file since I have more than 200 references. Thanks a lot! –  Avi Oct 15 '11 at 21:58
@Avi We only put references like this here on the site so that examples are self-contained. (The filecontents package just writes out its contents to a file.) So you would just have your references in your own bib file managed with e.g. JabRef (or BibDesk if you're using a Mac). You don't actually need a separate file for each chapter; you could just have one big file. –  Alan Munn Oct 15 '11 at 22:03
I think I can see what is going on.....I have citations (using \cite) within Figure captions. And this is what is screwing things up. So, for some reason the citations in the figure captions are automatically prioritized and bumped up to the top of the list and that in turn screws everything. –  Avi Oct 15 '11 at 22:11
I don't think there's an easy way around this. It's probably best to avoid such references when you are using a citation order scheme. –  Alan Munn Oct 15 '11 at 22:46
Well...I can't avoid the citations since I am referring to someone else's scientific work. I had already tried \protect to no avail....lets see...worst case I would have to remove the citation..but I am getting close to a solution. I think my original file was fine...the problem I feel was always the citations in the figure captions –  Avi Oct 15 '11 at 22:54
show 1 more comment

@Alan ...MOUNT EVEREST SCALED!!! The following solves all:

LaTeX Citations in Figures works very well.

\caption[Carrier mobilities of various forms of silicon. From Rogers et.al.]
{Carrier mobilities of various forms of silicon. From Rogers et.al.
\protect\cite{rogers:paper}


\caption{Carrier mobilities of various forms of silicon. From Rogers et.al.
\protect\cite{rogers:paper}


i have tried this with 10 citations and it works...citations appear in numerical order.

Wow....I don't need to defend my PhD anymore...this feels like a defense in itself! Thanks a TON guys. You are going into my acknowledgements (@Alan with a special mention!:))

-
@Avi I'm glad you found a solution (I had forgotten about the list of figures problem). But I think you've just gotten lucky so far. With a citation order scheme, it's still possible to have citations in floats appear in the wrong order independent of the solution you post here. Hopefully you won't encounter this. –  Alan Munn Oct 15 '11 at 23:14
BTW, It would be helpful if you edited your original question to show the actual problem you had, so that this answer matches it properly. –  Alan Munn Oct 15 '11 at 23:16
So Alan....what is the best solution? Not to use citations in Figure captions at all? –  Avi Oct 15 '11 at 23:17
updated problem statement to include the issue with citations within captions –  Avi Oct 15 '11 at 23:24
@Avi I don't know. I don't use this citation scheme generally. I've asked a new question to see if anyone here has some other ideas. Unsorted citations and floats –  Alan Munn Oct 15 '11 at 23:55
show 1 more comment