[Tex/LaTex] Control appearance of caption when using subfigures

captionsformatting

I am trying to style the name and text of captions so that the name ("Figure", "Table" etc) is in bold, and the title text (eg "A picture of a cat.") is in italics.Following the memoir manual I use:

\captiontitlefont{\small\itshape}
\captionnamefont{\small\bfseries}

So the following works, using memoir (produced by lyx):

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[11pt,a4paper,oneside,english,oldfontcommands,justified,a4paper]{memoir}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

\captiontitlefont{\small\itshape}
\captionnamefont{\small\bfseries}

\makeatother

\usepackage{babel}
\begin{document}
\begin{figure}
\caption{A picture of a cat.}

However, as soon as I add a subfigure, the caption is no longer styled. This does not work:

%% LyX 2.0.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[11pt,a4paper,oneside,english,oldfontcommands,justified,a4paper]{memoir}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

\captiontitlefont{\small\itshape}
\captionnamefont{\small\bfseries}

\@ifundefined{showcaptionsetup}{}{%
 \PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother

\usepackage{babel}
\begin{document}
\begin{figure}
\subfloat[My first cat.]{



}\caption{A picture of some cats.}


\end{figure}

\end{document}

I've also tried using:

\renewcommand{\fnum@figure}[1]{\textbf{\figurename~\thefigure} : }

but again this doesn't work when the subfig package is loaded.

(I am writing in French, using babel which also styles things ie putting FIGURE in uppercase, but that seems to be a separate issue).

How can I style my captions when using subfigures?

Best Answer

You can use the caption package along with subfig package. I have modified your code like below:

\documentclass[11pt,a4paper,oneside,english,oldfontcommands,justified,a4paper]{memoir}
\usepackage{mathpazo}
\usepackage[demo]{graphicx} %----------- remove [demo] in your file
\usepackage{subfig} %---------------- for subfigures
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{caption}%----------------------- added newly
%\captionsetup{labelfont={sc,bf}}%----------------------- added newly
\captionsetup[figure]{labelfont={bf,small,sc},textfont={it,small}}%----------------------- added newly
\captionsetup[subfloat]{labelfont={bf,small},textfont={it,small}}%----------------------- added newly
%
\usepackage{babel}
\begin{document}
%=========================
\begin{figure}
  \includegraphics[width=1\textwidth]{my figure}\\
  \caption{My single cat}\label{singlecat}
\end{figure}
%=========================
\begin{figure}[!h]
\centering
\subfloat[My first cat.]{\label{fig:cat1}{\includegraphics[width=0.4\textwidth]{my figure}}}\hfil
\subfloat[My second cat.]{\label{fig:cat2}{\includegraphics[width=0.4\textwidth]{my figure}}}
\caption{My two big cats}
\label{fig:cats}
\end{figure}
%===========================
\end{document} 

enter image description here

I have also put the FIGURE in SC letters.

Related Question