[Tex/LaTex] Using \ContinuedFloat creating errors with table captions

captionssubfloatstables

I have a figure in my document that has 10 subfigures, and overflows onto two pages. I have used two figure environments and \ContinuedFloat to get the correct lettering between subfloats. The problem now is that \caption no longer works in table environments. Here is an example of the problem.

\documentclass[12pt, a4paper]{article}
\usepackage{subfig}

\begin{document}

\begin{table}
\begin{center}
\caption{cat}
\begin{tabular}{|l|c|r|}
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
\caption{cat}
\label{cat}
\end{center}
\end{table}

\ref{cat}

\begin{figure}
\end{figure}

\begin{figure}
\ContinuedFloat
\end{figure}

\end{document}

Any help would be greatly appreciated.

Best Answer

You have to put a caption for the figure too to get an anchor there. Otherwise, the anchor from previous \caption will be taken (here it is a table) and throw an error.

.
.
.
\ref{cat}

\begin{figure}[htb]
\caption{Figure here}
\end{figure}

to get things right.

Code:

\documentclass[12pt, a4paper]{article}
\usepackage{subfig}

\begin{document}

\begin{table}[htb]
\centering
\caption{cat}\label{cat}
\begin{tabular}{|l|c|r|}
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
\end{table}

\ref{cat}

\begin{figure}[htb]
\caption{Figure here}
\end{figure}

\begin{figure}
\ContinuedFloat
\caption{continued here}
\end{figure}

\end{document}

enter image description here

Please note that center environment is not suitable for use with figure and table as it leaves extra (un-necessary) vertical space.