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{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{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}
Best Answer
I'm only aware of a single situation causing the error
Command \caption@ContinuedFloat already defined
:This is happening here: The
subfig
package is loaded with optioncaption=false
which means "No, I really don't want to use the caption package". Afterwards thecaption
package is loaded, causing the error since thesubfig
package has already defined some commands which are necessary for sub-figure support withoutcaption
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.