2

I'm using natbib, cleveref, bibtex and .bib files to generate my references, using \cite{reference}. At first, it does it very well, but when a re-compiling is done---with the same commands---, the appearing number of the references changes, instead of having 1, it has 2. The code:

\documentclass[10pt,letterpaper,hidelinks]{book}
\usepackage{hyperref}
\usepackage{graphicx}
\graphicspath{{figures/}}
\usepackage[numbers,sort&compress]{natbib}
\usepackage{cleveref}

\begin{document}
\frontmatter
\tableofcontents
\listoffigures
\listoftables

\bibliographystyle{unsrtnat}

\mainmatter
\include{fileWithReferences}

\appendix

\backmatter

\bibliography{articles,reports,books}

\end{document}

Since running latex -> bibtex -> latex -> latex is time consuming at first run, how can I fix the 're-ordering'? The fileWithReferences.tex looks like:

\chapter{Energy}

Some text \cite{Turcotte2002}, some other text \cite{Anderson1989}. In \cref{figure:AltEn} there's a reference to a book.

\begin{figure}[!ht]
    \centering
    \includegraphics[scale=.1]{Alternative_Energies.jpg}
    \caption{Alternative energies \cite{Anderson1989}}
    \label{figure:AltEn}
\end{figure}

Here another reference \cite{Turcotte2002}.

And the books.bib file looks like:

@book{Turcotte2002,
author = {D.L. Turcotte and G. Schubert},
title = {Geodynamics},
year = {2002},
OPTedition = {2nd.},
}

@book{Anderson1989,
author = {Don. L. Anderson},
title = {Theory of the Earth},
year = {1989},
}

Output (first run):

Output (first run)

Output (second run):

Output (second run)

lockstep
  • 250,273
Mario
  • 645
  • 5
    You can't be using biblatex and natbib at the same time and in fact the example file you include does not employ the biblatex package (i.e., there's no \usepackage{biblatex}). In addition, in order for others to examine the problem you describe, you must include at least one or two \cites. The line \include{fileWithReferences} is not something any one can test. – jon Jan 21 '14 at 04:04
  • Without information about the relevant contents of filewithreferences.tex, it's not possible to say for sure what's going on. It could be something as simple as an extra \cite command that has slipped in somewhere in the file. – Mico Jan 21 '14 at 07:25
  • Thanks for editing your posting to provide information about fileswithreferences.tex and books.bib. I must confess it's now unclear to me what your question or concern is. Please elaborate. Incidentally, while it may be helpful (or even important) to a citation call-out in the caption of a figure while you're looking at the figure, it's probably less useful (and possibly quite confusing) to have the numeric citation number show up in the List of Figures. You may thus want to write the caption command as \caption[Alternative energies]{Alternative energies \cite{Anderson1989}}. – Mico Jan 21 '14 at 22:46
  • As you can see by the output images, reference numbers order change when a re-compiling is done. it doesn't happen if I don't put references in a figure caption. In my batch file I have to include delete commands for any output file generated by latex and bibtex, but this is time-consuming. I want to know why the order change and how I can fix it (just re-compiling). – Mario Jan 21 '14 at 23:21
  • 1
    @Mico -- That might actually be the solution: I think the use of unsrtnat is (eventually) causing [2] to become [1] because it is appearing earlier in the document as part of the LoF. – jon Jan 21 '14 at 23:22
  • 2
    Similar questions have been asked before, e.g. http://tex.stackexchange.com/questions/36304/ignore-citations-in-captions-in-list-of-figures-when-numbering As an alternative to the suggestion of using the optional argument for the caption, you could try loading the notoccite package. – Torbjørn T. Jan 21 '14 at 23:27
  • Thanks! Although I'll do a lot of editing, it won't happen again. – Mario Jan 21 '14 at 23:31
  • Works flawlessly with the notoccite package. Thaks again. – Mario Jan 21 '14 at 23:36

0 Answers0