Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using TexMaker + BibTex + XeLaTeX and everything was fine, until I noticed that it was ordering the references by the .bib file order instead of the .tex file order. So it starts at [5] instead of [1] because my first citation it's the 5th element in the bib file.

This are the packages which I'm using:

\usepackage{graphicx} % images
\usepackage{fontspec} %font to show accents in xelatex
\usepackage{url} %for urls
\usepackage[portuguese]{babel} %portuguese documment
\usepackage{color} %for text color

I put the references before the end document:

\bibliographystyle{IEEEtran} %for IEEE references style
\bibliography{references}
\end{document}

Also I always do the F1-F11-F1-F1 to compile.

share|improve this question
    
Do you have a \nocite{*} command in your document? –  egreg May 20 '12 at 14:48
    
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. In the manual you will find: IEEEtran.bst: The standard IEEEtran BIBTEX style file (unsorted, i.e., references will appear in the order in which they are cited). Recommended for work that is to be submitted to the IEEE. –  Marco Daniel May 20 '12 at 14:50
    
Thanks egreg, you made my day. You are right I had a \nocite{*} %% This should output the entire bib file command hided in my document that was the cause of the wrong order. –  RandomGuy May 20 '12 at 14:52

1 Answer 1

up vote 4 down vote accepted

When a \nocite{*} appears in the document, all entries in the .bib database are automatically inserted in the bibliography, with the same order as specified by the chosen bibliography style, in the case of IEEEtran it's "unsorted".

Find the offending command and remove it, or place it at the end, where it won't influence the "unsorted" order of explicit citations. Of course, using \nocite{*} in such a document requires organizing the .bib file in some sensible order, so I'd recommend not using it. If you want to have some entry in the bibliography that wasn't cited in the document, use

\nocite{<key1>,<key2>,...}

just before the \bibliography{command}, where the keys are ordered as you wish.

share|improve this answer
    
That indeed solved the problem. I have just commented the \nocite{*} it's enough for me. Thank you very much! –  RandomGuy May 20 '12 at 21:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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