32

I am having an issue with LaTex/Bibtex presenting my citations in order of appearance. I know there a plenty of questions on this and I have read some of them, but the solutions posted don't seem to do me any good. I am using MacTeX and TeXmaker.

I am writing a large document, like a Thesis. Chapters are split between individual Tex files and included using the \include command.

I have a large .bib file that is maintained by Mendeley (program I use for storing my references and producing a BibTex file).

I am using the package, cite (mainly for doing references like [1-3,6,9])

I have a pretty standard looking document.

\documentclass[11pt,a4paper]{report}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\newcommand{\doubleSignature}[3][Alex Mason]{%
\parbox{\textwidth}{
\centering #3 \today\\
\vspace{2cm}

\parbox{7cm}{
  \centering
  \rule{6cm}{1pt}\\
   #1 
}
\hfill
\parbox{7cm}{
  \centering
  \rule{6cm}{1pt}\\
  #2
}
}
}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage[sorting=none]{biblatex}
%\bibliography{Alex} % Where journals.bib and phd-references.bi
\usepackage[pdftex]{graphicx}
\usepackage{enumerate}
\usepackage{nomencl}
\usepackage{wasysym}
\usepackage{booktabs}
\usepackage{cite}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
\graphicspath{{./Diagrams/}}
\usepackage[labelfont={sf,bf}, margin=1cm]{caption}
\usepackage{subcaption}
\renewcommand{\figurename}{Fig.}
\renewcommand{\tablename}{Tab.}
\renewcommand{\bibname}{References}
\author{NAME (MEng)}
\title{TITLE}
\date{\today}
\makenomenclature
%------------------------------------------------
\begin{document}
\maketitle
\pagenumbering{roman}
%-----------------------------------------------certificate of originality----------------      --------------------------------------------
\input{CertofOrigin}
\begin{abstract}
ABSTRACT
\end{abstract}
%-----------------------------------------------contents------------------------------------------------------------
\tableofcontents
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}
\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
ACKNOWLEDGEMENTS
\printnomenclature[1.5in]
\addcontentsline{toc}{chapter}{Nomenclature}
\pagebreak
\pagenumbering{arabic}
\include{2ndYearReport_CHAP1}
\include{2ndYearReport_CHAP2}
\include{2ndYearReport_CHAP3}
\bibliographystyle{unsrt}
\bibliography{Alex}
%\printbibliography
\end{document}

The goofy looking part at the top (\newcommand{doubleSig.....) is just for when i input a special page I made containing a certificate of originality spiel with two boxes for signatures and my university logo.

As you can see I am using the standard bibtex way of doing bibliographies by stating the style then the stating the bib file to use right at the end of the document. I have tried biblatex but can't get it to work. It says it hasn't produced the bib file but doesn't really state why.

As far as I am aware everything was working A-OK until I started on the second chapter and began adding citations in there. Now my citations are all messed up and won't correct. My first citation starts with [9]!!!

[1] appears in a figure caption later down the page, after 10, 11 and 12 have been called!

I have tried deleting all the working files (bbl, aux, log etc) but nothing happens. I get the same result. IIRC I used to have this problem with MS Word and is part of the reason why I switched to LaTex...yet it seems to have followed me!

bibtex does through a few warnings when it runs stating that some references are missing journal names or volume numbers. Would that be a reason?

What have I done wrong with my code?

5
  • 8
    By chance, are there 8 captions where you cite a reference? 8 places in the List of Tables or Figures numbered [1] through [8]? If so, try adding the notoccite package and see if that fixes it. Otherwise, please trim down your document to a more minimal version, and include a minimal .bib file. Jul 1 '12 at 19:07
  • 1
    You know I was just about to come back here and post that! I deleted everything but the .tex files and ran pdflatex, bibtex, pdflatex x2. Everything was good. Did the run to sort the Nomenclature out and I am back at square one. then I noticed the numbers in the list of figures pages done by\ listofffigures... the reference numbers are appearing there because I have images I need to reference. So latex is doing things right, I am doing it wrong. I will have a look at this notocite package.
    – Alex
    Jul 1 '12 at 19:23
  • 1
    Right adding the package notoccite \usepackage{notoccite} has solved this problem! Thank you very much Mr. Renfro! I would of been sat here for days trying to sort this! Thank you.
    – Alex
    Jul 1 '12 at 19:31
  • @MikeRenfro It worked perfectly, but why? Thanks! Apr 4 '15 at 16:46
  • @SibbsGambling it's explained in the answer below, I think. Is something missing there? Apr 4 '15 at 17:17
26

This problem crops up all the time when you have citations in your captions, or probably less commonly in document division titles. By default, LaTeX uses the citations in the List of Figures, List of Tables, or Table of Contents as the "first" citation, since it occurs before the main body text.

Options to fix this include:

  1. Adding the notoccite package to your preamble.
  2. The \ignorecitefornumbering command as shown in Get BibTeX to ignore citation numbering in a figure caption does largely the same thing as notoccite.
  3. Modifying the offending captions to have the form \caption[Caption without citation that appears in the List of Figures or Tables]{Caption with citation that appears with the figure or table itself}

If it were up to me, I'd go with option 1. Some editors or thesis committees may be happier with option 2. Example of option 1 (including natbib for \citeauthor command) follows:

enter image description here

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage{notoccite}
% If you have \cite commands in \section-like commands, or in \caption, the
% citation will also appear in the table of contents, or list of whatever.
% If you are also using an unsrt-like bibliography style, these citations
% will come at the very start of the bibliography, which is confusing. This
% package suppresses the effect.

\begin{filecontents}{\jobname.bib}
@misc{foo,
 author = {Foo},
 title = {Title of Foo},
}
@misc{bar,
 author = {Bar},
 title = {Title of Bar},
}
@misc{baz,
 author = {Baz},
 title = {Title of Baz},
}
\end{filecontents}

\begin{document}
\listoffigures

%\chapter{Introduction}
\section{The Beginning}
Here we cite \citeauthor{foo} \cite{foo}.
Now we cite \citeauthor{bar} \cite{bar}.
Finally, we cite \citeauthor{baz} \cite{baz}.
\begin{figure}[htbp]
\centering
\framebox[0.5\textwidth]{Here's a figure.}
\caption{Figure from \cite{bar}, which should most definitely \textbf{not}
         be numbered [1] in the LoF}
\end{figure}
\bibliographystyle{unsrtnat}
\bibliography{\jobname}
\end{document}
1
  • Tried so many things, this was the only one that worked reliably. Cheers!
    – Bryson S.
    Apr 18 '19 at 15:46
14

In Document»Settings»Bibliography choose the Default (numerical) bibliography style. And then go to Latex preamble section and write this code:

\bibliographystyle{unsrtnat}
\usepackage[numbers,sort&compress]{natbib}

This worked for me, it should work for you too.

2
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Nov 23 '14 at 13:20
  • 4
    Welcome to TeX.SX. Does this really solve the problem caused by citations in the list of figures? Also, you should mention that you're referring to LyX here. Nov 23 '14 at 13:20
2

I had same issue with a figure in my thesis. I resolved it by adding blank square brackets after \caption in the caption command as:

\caption[]{Figure showing ....\cite{Ref Label}}
1
  • I think it is understood. Anyway I have edited my code.
    – Ehsa
    Sep 9 '16 at 14:28
0

If your citing numbering does not appear in order try to change the compiler. It worked in my case. Keep in mind some commands/packages are compiler-specific.

LaTeX compilers options

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.
https://tex.stackexchange.com/questions/61869/latex-bibtex-not-arranging-citations-by-order-of-appearance
tex.stackexchange.com
crawl=CC-MAIN-2021-43
215285
application/http; msgtype=response
sha1:DNUBGBRJYKM2X6RWQYOQWZUAV6T3MFZY
<urn:uuid:f9581c93-d5ab-443c-99c7-687ffab4b455>
2021-10-26T12:26:54Z
151.101.65.69
text/html
sha1:T6UHLEACRUDYJNVRKJQTKYY53KGJ6X7P
<urn:uuid:e71b6d72-1989-4442-8580-81f2e49049a1>
https://tex.stackexchange.com/questions/61869/latex-bibtex-not-arranging-citations-by-order-of-appearance
response
<urn:uuid:b0f0b240-fa97-4e28-94ff-aab792057c82>
isPartOf: CC-MAIN-2021-43
publisher: Common Crawl
description: Wide crawl of the web for October 2021
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-227
software: Apache Nutch 1.18 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/