# Negative numbers being assigned to figures

I am using pdflatex distribution. I have many figures in the my latex document.

For some reason the numbering stars from Figure 1 ,then Figure 2. It then goes to Figure 0, -1, -2 and so on.

The subfigures are labelled in the reveres order, (d), (c), (b) ,(a) . Here is one of the examples:

\begin{figure}[h]
\centering
\caption{Some caption }\label{fig:figure1}
\begin{subfigure}[h]{\textwidth}
\includegraphics[width=0.8\textwidth]{3.pdf}
\caption{Less Reflective Object}\label{fig:lessreflec}
\caption*{More text}
\end{subfigure}
\end{figure}

\begin{figure}[h]
\centering
\ContinuedFloat
\begin{subfigure}[h]{\textwidth}
\includegraphics[width=0.8\textwidth]{4.pdf}
\caption{Another caption}
\caption*{ some text}
\label{fig:irkey}
\end{subfigure}
\end{figure}

-
Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages. –  Peter Grill Nov 2 '12 at 3:31
Related (if using subfig): ContinuedFloat, and Subfloat –  Werner Nov 2 '12 at 4:28

## 1 Answer

The intent of \ContinuedFloat (of subcaption) is to drop the environment counter by 1 and store the state of the sub-environment numbering so that it can be carried over to a subsequent floating environment (otherwise they would typically be reset when the environment counter is incremented - which happens when you issue \caption). Here's a more structured/commented look at it when looking at the figure and subfigure environments:

\begin{figure}% <-- sets the caption type to figure
\caption{..}% <-- increments the caption type counter (figure in this case)
% figure content and possible subfigures
\end{figure}

% textual content

\begin{figure}% <-- sets the caption type to figure
\ContinuedFloat% <-- decreases the caption type counter by 1 (figure in this case)
% figure content and possible subfigures
\end{figure}


The problem with this is that subsequent figures with \caption will not have the correct counter, since it's reduced with every issue of \ContinuedFloat if you don't have an accompanying \caption to step it again. That's why subcaption offers \phantomcaption if you don't want a full caption but still have appropriate numbering - the missing step. So, your full usage should actually resemble:

\begin{figure}% <-- sets the caption type to figure
\caption{..}% <-- increments the caption type counter (figure in this case)
% figure content and possible subfigures
\end{figure}

% textual content

\begin{figure}% <-- sets the caption type to figure
\ContinuedFloat% <-- decreases the caption type counter by 1 (figure in this case)
% figure content and possible subfigures
\phantomcaption% <-- increases the caption type counter by 1 (figure in this case)
\end{figure}


Without a complete minimal working example (MWE), it is not easy to understand why your subfigures may be out of sync.

-
my pdftex version(3.14) did not support \phantomcaption , so I added \caption after each \ContinuedFloat to solve my problem. Thank you! –  Dhananjay Nov 3 '12 at 1:46