# How to resolve the inconsistency between the reference number in the text and bibliography?

Suppose my text has three references A, B, and C. If I cite them in order, the corresponding numbers are consistent. However, if I change the order in the bibitem, the numbers are inconsistent. For example,

"I refer to \cite{A}, then \cite{B}, then \cite{C}."


And the bibliography is

\begin{thebibliography}{}
\bibitem{C}
cccccccc
\bibitem{B}
bbbbbbbb
\bibitem{A}
aaaaaaaa
\end{thebibliography}


The output is this: "I refer to [3], then [2], then [1]." To fix this, I should switch the first and third bibitems, but suppose I am writing a paper with more than 50 references, and after revising the paper I notice that I should add another reference somewhere in the text. In this case the easiest way is choosing a name for the reference, say \cite{myforgotten} and add it to the bibitem. But, as we saw, it causes an inconsistency. Is there any way to fix this, or I have to put the bibitems exactly in order?

• Welcome to TeX.SX! There's a reason BibTeX and BibLaTeX have been invented. You probably want to use one of them instead of your thebibliography environment. – TeXnician Aug 2 '18 at 16:53

You appear to be mixing up two conceptually very different things: the "key" of an entry, and the number that the entry is assigned, assuming numeric-style citation call-outs are in use (as would appear to be the case for your code snippet).

• The "key" of each bibliographic entry. In your code snippet, you've named the keys A, B, and C. More frequently, the keys are selected to be at least somewhat mnemonic of the associated entry. E.g., if a piece was authored by Adam Jones and Zebedee Smith in 2007, one might choose the key of that piece to be jones-zebedee:07.

• The "number" that's assigned to each entry. The numbers are critically important for numeric-style citation call-outs; for authoryear-style citation call-outs, the numbers are nearly irrelevant and are generally not even shown.

If one builds the thebibliography by hand, each \bibitem must feature the required argument, which is the key. Each \bibitem can also feature an optional argument, which will help determine what the citation call-out will look like. If the optional arguments of the \bibitems are omitted, the formatted bibliographic items will be numbered consecutively in ascending order, and the citation call-outs will also consist of numbers (often, but not always, surrounded by square brackets).

Suppose that the hand-built thebibliography environment looked like this:

\begin{thebibliography}{9}
\bibitem[66]{C}
cccccccc

\bibitem[1001]{B}
bbbbbbbb

\bibitem[77]{A}
aaaaaaaa

\end{thebibliography}


LaTeX would use the number 66 for citation call-outs to the item with key C, the number 1001 to the item with key B, and the number 77 to item with key A. The ordering in which the items would appear in the bibliography would be C, B, and A. If you were to re-order the items by hand, so that A comes before B and C comes after B, but don't change the optional arguments, they'll still be numbered 77, 1001, and 66.

Building bibliographies by hand is both exceedingly tedious and highly error-prone. If you foresee writing more than a couple of working papers using LaTeX in your career, you'll do yourself a huge favor by learning the basics of creating bibliographies using software tools such as natbib, biblatex, BibTeX, and biber.