Using an up-to-date TeXlive 2012 (with all updates) this small document will produce a strange AUX file:
\documentclass{book}
\usepackage[list=on]{subcaption}
% Suppress writing the definition of \caption@xref to the AUX file (does not help)
\makeatletter
\let\caption@@@xlabel\@empty
\makeatother
% Show the order of \addcontentsline use
\let\xxxxx\addcontentsline
\renewcommand\addcontentsline[3]{%
\typeout{#1 - #2}%
\xxxxx{#1}{#2}{#3}}
\begin{document}
\listoffigures
\begin{figure}
\centering
\subcaptionbox{\label{A}}{A}
\subcaptionbox{\label{B}}{B}
\caption{X}
\end{figure}
\end{document}
As you see from the output of the redefined \addcontentsline the order of the usage of \addcontentsline by the caption package is:
lof - figure
lof - subfigure
lof - subfigure
But the AUX file contains afterwards:
\relax
\@writefile{lof}{\contentsline {subfigure}{\numberline {a}{\ignorespaces \caption@gobble {A}\relax }}{1}}
\@writefile{lof}{\contentsline {subfigure}{\numberline {b}{\ignorespaces \caption@gobble {B}\relax }}{1}}
\newlabel{A}{{1a}{1}}
\newlabel{sub@A}{{a}{1}}
\newlabel{B}{{1b}{1}}
\newlabel{sub@B}{{b}{1}}
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces X\relax }}{1}}
So the order of code lines within the AUX file does not correspond to the order of the usage of \addcontentsline.
Does anybody know what is going on here and how to fix this?
P.S.: For a reason I don't understand yet the example document works fine when using v3.2f of my caption package but fails with version v3.3 -- although I haven't changed the algorithm for delaying the sub-figure LOF entries.
\showoutputafter adding[p]then the write node for the main caption is in the figure box, but the two write nodes for the sub caption are outside the figure box at the end of the first page. – David Carlisle Mar 09 '13 at 21:38\addcontentslineyesterday that I was not even considering that it actually could be a very simple error of mine, and therefore I did not do investigations in other directions. In fact I forgot to redefine an internal macro after changing a hook within my add-contentline-stuff. So maybe we should close this question as too localized? – Mar 10 '13 at 09:53