Without a complete example, it is impossible to be sure. However, I suspect the problem is the result of the following 2 points:
- without a
\caption
or \phantomcaption
, \ContinuedFloat
will not work;
\phantomcaption
is defined by caption
which you have told subfig
ought not be loaded - hence, it is undefined.
Note that compiling non-stop is great but it is not the way to diagnose problems. Ignore errors at your peril. In this case, LaTeX will have failed compilation with an error which would have told you precisely the problem. If you must ignore errors, you have to read the .log
assiduously not only when there is an obvious problem, but to find problems of a more subtle variety.
Here's my version of your example, borrowing code from Zarko's efforts:
\documentclass{article}
\usepackage[labelsep=space,
labelfont={sf,bf},
textfont=sf,
caption=false]{subfig}
\usepackage{graphicx,kantlipsum}
\begin{document}
\begin{figure}[!ht]
% \centering
%%image-1
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}
\caption{Assignment of pixels 1.}
\label{image:assignSP1}
\end{figure}
\begin{figure}[!ht]
% \centering
%%image-1
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}
\caption{Assignment of pixels 2.}
\label{image:assignSP2}
\end{figure}
\begin{figure}[!ht]
% \centering
%%image-1
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[]{\includegraphics[width=0.24\hsize,height=1cm]{example-image}}
\caption{Assignment of pixels 3.}
\label{image:assignSP3}
\end{figure}
\kant[1]
\begin{figure}[!ht]
%%image-2
\subfloat[Original image1] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-11, Subgraph-1] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-11, Segmentation] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-11, Saliency] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\\
%%Layer-2
\subfloat[Layer-12, Subgraph-1] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-12, Subgraph-2] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-12, Segmentation] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-12, Saliency] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}
\phantomcaption
\end{figure}
\vfill
%%mages on the new page
\begin{figure}[!ht]
\ContinuedFloat
\subfloat[Layer-14, Segmentation] {\includegraphics[width=0.48\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-14, Saliency] {\includegraphics[width=0.48\hsize,height=1cm]{example-image}}
\caption{corresponding maps 1.}
\label{image:Hierarchy1}
\end{figure}
\kant[2-3]
\begin{figure}[!ht]
%%image-2
\subfloat[Original image2] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-21, Subgraph-1] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-21, Segmentation] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-21, Saliency] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\\
%%Layer-2
\subfloat[Layer-22, Subgraph-1] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-22, Subgraph-2] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-22, Segmentation] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-22, Saliency] {\includegraphics[width=0.24\hsize,height=1cm]{example-image}}
\phantomcaption
\end{figure}
\vfill
%%mages on the new page
\begin{figure}[!ht]
\ContinuedFloat
\subfloat[Layer-24, Segmentation] {\includegraphics[width=0.48\hsize,height=1cm]{example-image}}\hfill
\subfloat[Layer-24, Saliency] {\includegraphics[width=0.48\hsize,height=1cm]{example-image}}
\caption{corresponding maps 2.}
\label{image:Hierarchy2}
\end{figure}
\end{document}
We do not actually need this much. A single figure followed by some filler text, the first part of a figure and the continuation would be quite sufficient to demonstrate the issue:
\documentclass{article}
\usepackage[labelsep=space,
labelfont={sf,bf},
textfont=sf,
caption=false]{subfig}
\usepackage{graphicx}
\begin{document}
\begin{figure}[!ht]
\subfloat[]{\includegraphics[width=\linewidth]{example-image-a}}
\caption{Assignment of pixels 1.}
\label{image:assignSP1}
\end{figure}
\begin{figure}[!ht]
\subfloat[Original image1] {\includegraphics[width=.45\linewidth]{example-image-4x3}}\hfill
\subfloat[Layer-12, Subgraph-1] {\includegraphics[width=.45\linewidth]{example-image-4x3}}
\phantomcaption
\end{figure}
\vfill
%%mages on the new page
\begin{figure}[!ht]
\ContinuedFloat
\subfloat[Layer-14, Segmentation] {\includegraphics[width=\linewidth]{example-image-b}}\hfill
\caption{corresponding maps 1.}
\label{image:Hierarchy1}
\end{figure}
\end{document}
which, if we ignore the errors and carry blithely on, gives us:
which clearly shows the problem: figure 2 on page 2 is numbered 1.
When we try to compile this, compilation fails with the following error:
! Undefined control sequence.
l.24 \phantomcaption
?
That is, it complains that \phantomcaption
is not defined. This is bad because \ContinuedFloat
requires a \caption
to work. subfig
assumes that the first part of a figure
will always have a \caption
. That caption increments the figure
counter. No \caption
means no increment. Meanwhile, \ContinuedFloat
explicitly prevents the \caption
in the second part from incrementing the figure
counter.
The solution to this is \phantomcaption
which ensures that the counter is incremented. But subfig
does not provide this command. caption
provides it. But by setting caption=false
, we have told subfig
that caption
is not to be loaded.
For further details, see Axel Sommerfeldt's answer on this topic.
So, there are two obvious options:
- set
caption=true
;
- use a real
\caption
.
In the absence of more details, option 1 seems the better choice. Setting caption=true
in the options to subfig
resolves the issue nicely:
Option 2, adding \caption{first part}
to the first part of the figure
achieves precisely the same result for the second part plus, of course, an additional caption for the first.
If for some reason neither of these are options, the only other choice I can see is to implement something yourself. For example adding the following to your preamble:
\newcommand*\phantomfigurecaption{\stepcounter{figure}}
\newcommand*\phantomtablecaption{\stepcounter{table}}
would allow you to use \phantomfigurecaption
in the first part of the figure
to achieve roughly the same result. But note that this is a hack and will be much less robust than using one of the options provided by the packages. I do not recommend doing it this way unless you really have no better option.
Best Answer
(Updated to include @Mico's suggestion of a
\bigskip
.)Here's one possibility that makes use of
\parbox
es. This solution makes sense, I think, if you want all of the figures to have a figure number that increases.You can change the length for the first two
\parbox
es and the length for the first two\includegraphics
commands if you want the top two figures to be smaller and not span the entire width of the overallfigure
environment.There are also the
subfig
andsubcaption
packages that allow you to have subfigures (e.g., the labels will be something like Figure 1(a), Figure 1(b), etc.; see, for starters, subcaption vs. subfig: Best package for referencing a subfigure and also Jesse's answer for a concrete example).