[Tex/LaTex] subcaption package incompatible with memoir class

memoirsubcaptionsubfloats

When I try to compile a document with the memoir class and the subcaption package I get the following error:

! Package subcaption Error: This package can't be used in
cooperation with the subfig package.

I presume this is because the memoir class loads the subfig package. Is that correct?

Is there a way to make them work together?

Best Answer

The subfig and subcaption packages can not be used in cooperation with each other. Instead, you can usecaption package with subfig to add some flavor to the captions and subcaptions (or you can use caption along with subcaption (which gives a subfigure command also).

\documentclass{memoir}
\usepackage[demo]{graphicx} % remove [demo] in your file
\usepackage{subfig} % for subfigures
\usepackage{caption}
\usepackage{lipsum}

\captionsetup[figure]{labelfont={bf,small},textfont={it,small}}
\captionsetup[subfloat]{labelfont={bf,small},textfont={it,small},
subrefformat=parens} %<-----designing subcaption
\newcommand{\myfigref}[2]{~\ref{#1}.\subref{#2}}% <---- a new macro for referring to a subfigure
%    
\begin{document}
%=========================
\chapter{First chapter}
\lipsum[1-4]
%=========================
\begin{figure}[ht]
  \includegraphics[width=1\textwidth]{my figure}
  \caption{My single picture}\label{fig:figures}
\end{figure}
%=========================
\begin{figure}[ht]
\centering
\subfloat[My first picture]{\label{fig:mdleft}{\includegraphics[width=0.4\textwidth]{my figure}}}\hfill
\subfloat[My second picture]{\label{fig:mdright}{\includegraphics[width=0.4\textwidth]{my figure}}}
\caption{My two big pictures}
\label{fig:subfigures}
\end{figure}
%===========================
From figure~\ref{fig:subfigures}.\subref{fig:mdleft}, we can see a small cat, in     
\myfigref{fig:subfigures}{fig:mdright} both can be used to refer figures.
\end{document}

enter image description here

Related Question