[Tex/LaTex] Natbib numbering problem

bibliographiescitingnatbib

I have to use natbib for a conference paper bibliography and I'm having trouble getting the numbering working. I have the following code:

...
\usepackage[numbers]{natbib}
...
\begin{document}
...
\bibliographystyle{unsrtnat}
\bibliography{FAR_citations}
\end{document}

With the following in FAR_citations.bib:

@ONLINE {spy_camera,
    author = "Adafruit",
    title  = "Spy Camera for Raspberry Pi",
    year   = "2015",
    howpublished = {\url{https://www.adafruit.com/products/1937}}
}

@ONLINE {raspberry_pi,
    author = "Adafruit",
    title  = "Raspberry Pi Model B+ 512MB RAM",
    year   = "2015",
    howpublished = {\url{http://www.adafruit.com/products/1914}}
}

@ONLINE {powerboost,
    author = "Adafruit",
    title  = "PowerBoost 500 Basic - 5V USB Boost at 500mA from 1.8V+",
    year   = "2015",
    howpublished = {\url{https://www.adafruit.com/products/1903}}
}

The output is:

enter image description here

The following are my problems:

  1. How do I make natbib sort the order of the citations by their order of appearance in the document?
  2. How do I make natbib put [1], [2], etc. instead of these weird [Ada15a], [Ada15b] type citations?

Thanks a lot for your help!

Best Answer

The screenshot and description you've posted give the impression that you used to work with the alpha citation call-out style (probably achieved by specifying the bibliography style alpha, or something very similar) before switching over to an unsorted numeric call-out style, to be achieved by (a) using the unsrtnat bibliography style and (b) loading the natbib citation management package with the option numbers.

After switching bibliography styles, it is mandatory to recompile the document with LaTeX, re-run BibTeX, and then re-run LaTeX twice more in order to propagate all changes. Did you remember to run this four-step process?

Two additional comments/suggestions:

  • The entry type @online is not actually defined by either the unsrtnat or the alpha bibliography style. In such cases, BibTeX falls back on the catch-all entry type @misc to format the entries. The @misc entry type recognizes and knows how to process the field named howpublished.

  • Be sure to prevent BibTeX from lowercasing uppercase-letter acronyms -- such as USB, RAM, and MB -- that occur in the title fields of your entries. The easiest way to achieve this is to encase the contents of the title fields in curly braces.

Here's a modified version of your code that achieves your stated objectives and also preserves uppercase spelling of words in the title fields.

\RequirePackage{filecontents}
\begin{filecontents}{FAR_citations.bib}
@ONLINE {spy_camera,
    author = "Adafruit",
    title  = "Spy Camera for {Raspberry Pi}",
    year   = "2015",
    howpublished = {\url{https://www.adafruit.com/products/1937}},
}

@ONLINE {raspberry_pi,
    author = "Adafruit",
    title  = "{Raspberry Pi Model B+ 512MB RAM}",
    year   = "2015",
    howpublished = {\url{http://www.adafruit.com/products/1914}},
}

@ONLINE {powerboost,
    author = "Adafruit",
    title  = "{PowerBoost 500 Basic---5V USB Boost at 500mA from 1.8V+}",
    year   = "2015",
    howpublished = {\url{https://www.adafruit.com/products/1903}},
}
\end{filecontents}

\documentclass{article}
\usepackage[numbers]{natbib}
\bibliographystyle{unsrtnat}
\usepackage[hyphens]{url}

\begin{document}
\cite{powerboost}, \cite{raspberry_pi}, and \cite{spy_camera}.
\bibliography{FAR_citations}
\end{document} 
Related Question