# figure numbering (via \ref{fig-label-name}) when using user defined myCaption

I want to change the font of Figure, and the caption text.

I tried caption package. But \usepackage[labelfont=bf,font=it]{caption} raises an error Command \caption@ContinuedFloat already defined..

Then I just define my quick-and-dirty \myCaption: \newcommand{\myCaption}[1]{\textbf{\caption{\textnormal{\textit{#1}}}}}.

But I notice that the figure numbering (via \ref) is sort like section numbering rather than the number after Figure.

EDIT add an example, it raises the error ! LaTeX Error: Command \caption@ContinuedFloat already defined

\documentclass[10pt]{book}

%%%%%% other packages in my doc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{amssymb, amstext, amsmath}
\usepackage{tikz}
\usepackage{pgfplots} % only 4 figure caroleError

%\usepackage{subfig}
\usepackage[caption=false]{subfig}

% for landscape figure
\usepackage{rotating}
\usepackage{color}
%\usepackage{minipage}
\usepackage{todonotes}
%\usepackage{xparse}
%\usepackage{fontspec,xltxtra,xunicode}
\usepackage{docmute}

\usepackage{here}
\usepackage{float}
%\usepackage{hliFigure}
\usepackage{csquotes}

\usepackage{afterpage}

% end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% for this minimum example:
% expand \figure to multi pages
\makeatletter
\renewenvironment{figure}[1][]{%
\def\@captype{figure}%
\par\nobreak\begin{center}\nobreak}
{\par\nobreak\end{center}}
\makeatother

\usepackage{graphicx}
\usepackage[labelfont=bf,font=it]{caption}

\usepackage[caption=false]{subfig}

\begin{document}

\begin{figure}\centering
\subfloat[]{\label{}\includegraphics[width=0.95\linewidth{linux_penguin.jpg}}\\
\subfloat[]{\label{}\includegraphics[width=0.95\linewidth]{linux_penguin.jpg}}\\
\subfloat[]{\label{}\includegraphics[width=0.95\linewidth]{linux_penguin.jpg}}\\
\subfloat[]{\label{}\includegraphics[width=0.95\linewidth]{linux_penguin.jpg}}\\
\caption{many figures}
\label{}
\end{figure}

\end{document}

• Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – jub0bs Aug 22 '13 at 11:38

I'm only aware of a single situation causing the error Command \caption@ContinuedFloat already defined:

\documentclass{report}
\usepackage[caption=false]{subfig}
\usepackage{caption}
\begin{document}
A
\end{document}


This is happening here: The subfig package is loaded with option caption=false which means "No, I really don't want to use the caption package". Afterwards the caption package is loaded, causing the error since the subfig package has already defined some commands which are necessary for sub-figure support without caption package.

The solution is simple: Please decide if you want to use the caption package, yes or no. (And especially not "no and yes", as stated in my example document.)

And now to Part 2, the "section numbering rather than the number after Figure" problem:

\label must be placed within the same group as \caption, so {\caption{...}}\label{...} fails. But this is what you do inside your definition of \myCaption, the \caption command is typeset inside \textbf{...} while the \label is not. Therefore \ref is doomed to fail here, giving you the reference to the last labeling command (e.g. \section) instead.