[Tex/LaTex] Sequential numbering of \cite inside figure \caption

bibliographiesnatbibnumbering

I have a document with figures, list of figures, and bibliography. When the list of references is being built, it places all \cites inside figure captions first, and only then it starts placing all the other references in the document. Is there a way to change the numbering to match the sequential order of the references as they appear in the document body?

MWE:
document.tex

\documentclass{article}
\usepackage[square,numbers]{natbib}

\begin{document}
\listoffigures

\section{MWE}
First, there's a body of text with a first reference.\cite{ref1}
\begin{figure}[htbp]
    \centering
    \caption{Here's a figure, which uses a second reference.\cite{ref2}}
\end{figure}
And after the figure, we have another piece of text, using a third reference.\cite{ref3}

\bibliographystyle{IEEEtran}
\bibliography{library}
\end{document}

library.bib

@Article{ref1,
    author  = {Papa, Umberto and Del Core, Giuseppe},
    title   = {Design and Assembling of a low-cost Mini UAV Quadcopter System},
    journal = {Department of Science and Technology, University of Naples" Parthenope},
    year    = {2014},
    file    = {:Design and Assembling of a low-cost Mini UAV Quadcopter System.pdf:PDF},
}

@InProceedings{ref2,
    author    = {P. Kosobutskyy and R. Ferens},
    title     = {Statistical analysis of noise measurement system based on accelerometer-gyroscope GY-521 and Arduino platform},
    booktitle = {14th International Conference The Experience of Designing and Application of CAD Systems in Microelectronics (CADSM)},
    year      = {2017},
    pages     = {405-407},
    month     = {Feb},
    doi       = {10.1109/CADSM.2017.7916162},
    file      = {:Statistical analysis of noise measurement.pdf:PDF},
    keywords  = {Accelerometers;Fluctuations;Force;Gyroscopes;Microcontrollers;Noise measurement;Power harmonic filters;Arduino;CADSM 2017;accelerometer;analysis},
}

@Article{ref3,
    author  = {Luukkonen, Teppo},
    title   = {Modelling and control of quadcopter},
    journal = {Independent research project in applied mathematics, Espoo},
    year    = {2011},
    file    = {:Modelling_and_control_of_quadcopter_Scho.pdf:PDF},
}

Output:
Output of the MWE

You can see that reference 2 (being referenced in the figure caption) appears first, because it is included in the list of figures.

Best Answer

Add the package notoccite.

\documentclass{article}
\usepackage[square,numbers]{natbib}
\usepackage{filecontents,notoccite}
\begin{filecontents*}{library.bib}
@Article{ref1,
    author  = {Papa, Umberto and Del Core, Giuseppe},
    title   = {Design and Assembling of a low-cost Mini UAV Quadcopter System},
    journal = {Department of Science and Technology, University of Naples" Parthenope},
    year    = {2014},
    file    = {:Design and Assembling of a low-cost Mini UAV Quadcopter System.pdf:PDF},
}

@InProceedings{ref2,
    author    = {P. Kosobutskyy and R. Ferens},
    title     = {Statistical analysis of noise measurement system based on accelerometer-gyroscope GY-521 and Arduino platform},
    booktitle = {14th International Conference The Experience of Designing and Application of CAD Systems in Microelectronics (CADSM)},
    year      = {2017},
    pages     = {405-407},
    month     = {Feb},
    doi       = {10.1109/CADSM.2017.7916162},
    file      = {:Statistical analysis of noise measurement.pdf:PDF},
    keywords  = {Accelerometers;Fluctuations;Force;Gyroscopes;Microcontrollers;Noise measurement;Power harmonic filters;Arduino;CADSM 2017;accelerometer;analysis},
}

@Article{ref3,
    author  = {Luukkonen, Teppo},
    title   = {Modelling and control of quadcopter},
    journal = {Independent research project in applied mathematics, Espoo},
    year    = {2011},
    file    = {:Modelling_and_control_of_quadcopter_Scho.pdf:PDF},
}
\end{filecontents*}

\begin{document}
\listoffigures

\section{MWE}
First, there's a body of text with a first reference.\cite{ref1}
\begin{figure}[htbp]
    \centering
    \caption{Here's a figure, which uses a second reference.\cite{ref2}}
\end{figure}
And after the figure, we have another piece of text, using a third reference.\cite{ref3}

\bibliographystyle{IEEEtran}
\bibliography{library}
\end{document}

enter image description here

Related Question