GeneralGetting wrong figure caption number using \ContinuedFloat

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
pallav
Posts: 170
Joined: Wed Nov 12, 2008 5:53 pm

Getting wrong figure caption number using \ContinuedFloat

Post by pallav »

I have used ContinuedFloat to get figures which are divided into two pages. For my case, I am getting the 1st fig caption no. as Figure 1 and the 2nd as Figure 0. I want the Fig no same (Figure 1). My code is

Code: Select all

\documentclass[a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{lmodern,mathpazo}
\usepackage[T1]{fontenc}
\usepackage[babel=true]{microtype}
\usepackage{subfig,float}
\usepackage{hyperref}
\hypersetup{colorlinks = true,linkcolor = blue, anchorcolor = blue, citecolor = blue, pdfstartpage=1, filecolor = red,urlcolor = red}
\begin{document}

\begin{figure}
\centering
\subfloat[]{\label{fig:11}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:12}\includegraphics[width=0.43\textwidth]{fig2}}
\subfloat[]{\label{fig:13}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:14}\includegraphics[width=0.43\textwidth]{fig2}}
\qquad
\subfloat[]{\label{fig:15}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\caption{Here are the first 5 figures of a continued figure.}
\label{fig:cont}
\end{figure}

\begin{figure}
\ContinuedFloat
\centering
\subfloat[]{\label{fig:21}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:22}\includegraphics[width=0.43\textwidth]{fig2}}
\qquad
\subfloat[]{\label{fig:23}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:24}\includegraphics[width=0.43\textwidth]{fig2}}
\qquad
\subfloat[]{\label{fig:25}\includegraphics[width=0.43\textwidth]{fig1}}
\caption{Here are the last 5 figures of a continued figure.}
\label{fig:cont}
\end{figure}

From Fig. \ref{fig:12}, \ref{fig:15}, \ref{fig:21}, \ref{fig:24} we can claim
\end{document}
Although the reference numbers are obtained as 1a, 1b, ... 1i, 1j. I have identified that if I remove \usepackage{hyperref} then the problem solved. But hyperref is a must to write my article. Please help me to solve the problem.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Getting wrong figure caption number using \ContinuedFloat

Post by Johannes_B »

Hyperref is making trouble here. Put the command \ContinuedFloat after the caption of the first float as a workaround.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
pallav
Posts: 170
Joined: Wed Nov 12, 2008 5:53 pm

Getting wrong figure caption number using \ContinuedFloat

Post by pallav »

Thanks for the reply Johannes_B.

Do you want to mention this?

Code: Select all

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to writeLaTeX --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you give
% someone the link to this page, they can edit at the same
% time. See the help menu above for more info. Enjoy!
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{lmodern,mathpazo}
\usepackage[T1]{fontenc}
\usepackage[babel=true]{microtype}
\usepackage{subfig,float}
\usepackage{hyperref}
\hypersetup{colorlinks = true,linkcolor = blue, anchorcolor = blue, citecolor = blue, pdfstartpage=1, filecolor = red,urlcolor = red}
\begin{document}

\begin{figure}
\centering
\subfloat[]{\label{fig:11}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:12}\includegraphics[width=0.43\textwidth]{fig2}}
\subfloat[]{\label{fig:13}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:14}\includegraphics[width=0.43\textwidth]{fig2}}
\qquad
\subfloat[]{\label{fig:15}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\caption{Here are the first 5 figures of a continued figure.}
\ContinuedFloat
\label{fig:cont}
\end{figure}

\begin{figure}
%\ContinuedFloat
\centering
\subfloat[]{\label{fig:21}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:22}\includegraphics[width=0.43\textwidth]{fig2}}
\qquad
\subfloat[]{\label{fig:23}\includegraphics[width=0.43\textwidth]{fig1}}
\qquad
\subfloat[]{\label{fig:24}\includegraphics[width=0.43\textwidth]{fig2}}
\qquad
\subfloat[]{\label{fig:25}\includegraphics[width=0.43\textwidth]{fig1}}
\caption{Here are the last 5 figures of a continued figure.}
\label{fig:cont}
\end{figure}

From Fig. \ref{fig:12}, \ref{fig:15}, \ref{fig:21}, \ref{fig:24} we can claim
\end{document}
The problem of numbering of caption has been solved but the numbering of sub-figure has been disturbed. Please help.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Getting wrong figure caption number using \ContinuedFloat

Post by Johannes_B »

There are always package incompatibilities (and there always will
be) between packages, all authors do their best, but as this is
done as a hobby of all authors in their spare time ...

Package subfig is known for it's incompatibility with hyperref.
Good thing is, there is an alternative called subcaption. Both
load the same base package called caption. The
difference, subcaption is developed by the same author as caption
and still actively maintained.
It is a little more to write, to be honest, but there are much
more possibilities and hooks. Please have a look.

Code: Select all

\documentclass[a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{hyperref}
\hypersetup{colorlinks = true,linkcolor = blue, anchorcolor = blue, citecolor = blue, pdfstartpage=1, filecolor = red,urlcolor = red}
\begin{document}

\begin{figure}
	\centering
	\begin{subfigure}{.45\linewidth}
		\includegraphics[width=\linewidth]{fig1}
		\caption{}
		\label{fig11}
	\end{subfigure}
	\begin{subfigure}{.45\linewidth}
		\includegraphics[width=\linewidth]{fig1}
		\caption{}
		\label{fig12}
	\end{subfigure}
	\begin{subfigure}{.45\linewidth}
		\includegraphics[width=\linewidth]{fig1}
		\caption{}
		\label{fig13}
	\end{subfigure}
	\caption{Here are the first 5 figures of a continued figure.}
	\label{fig:cont}
\end{figure}

\begin{figure}
	\ContinuedFloat
	\centering
	\begin{subfigure}{.45\linewidth}
		\includegraphics[width=\linewidth]{fig1}
		\caption{}
		\label{fig14}
	\end{subfigure}
	\begin{subfigure}{.45\linewidth}
		\includegraphics[width=\linewidth]{fig1}
		\caption{}
		\label{fig15}
	\end{subfigure}
	\begin{subfigure}{.45\linewidth}
		\includegraphics[width=\linewidth]{fig1}
		\caption{}
		\label{fig16}
	\end{subfigure}
	\caption{Here are the last 5 figures of a continued figure.}
\end{figure}

From Fig. \ref{fig11}, \ref{fig13}, \ref{fig14},
\ref{fig16} we can claim
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
pallav
Posts: 170
Joined: Wed Nov 12, 2008 5:53 pm

Re: Getting wrong figure caption number using \ContinuedFloa

Post by pallav »

Thank you very much. I am amazed. Its really helpful.
Post Reply