5

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?

4
  • 1
    you can use caption package and say \captionsetup[figure]{labelfont={bf,small},textfont={it,small}} to get the desired effect.
    – user11232
    Commented Mar 19, 2012 at 9:47
  • Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you.
    – egreg
    Commented Mar 19, 2012 at 10:02
  • @HarishKumar - works great, thanks! Its a comment so can't mark as an answer though.
    – user8786
    Commented Mar 19, 2012 at 10:38
  • 1
    The code \@ifundefined{showcaptionsetup}{}{\PassOptionsToPackage{caption=false}{subfig}]\usepackage{subfig} is IMHO rubbish. Just use \usepackage[caption=false]{subfig} and the caption package will no longer be loaded, and therefore your memoir caption settings will still work.
    – user2574
    Commented Mar 20, 2012 at 7:41

2 Answers 2

3

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.

3

Instead of the suggested code

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

declare a new subfloat type

\newsubfloat{figure}

and then

\begin{figure}

\subbottom[My first cat.]{<a picture>}

\caption{A picture of some cats.}

\end{figure}

If you want to use \subfloat, add

\newcommand{\subfloat}{\subbottom}

after \newsubfloat{figure}.

1
  • Thanks for the quick response. If I use \subbottom[My first cat.]{\includegraphics{mycat}} I get "undefined control sequence". Is there something I am doing wrong? (I have removed the subfig code).
    – user8786
    Commented Mar 19, 2012 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .