# memoir class with subcaption and hyperref packages

This is similar to this question about using subfigures in memoir class and this one about using subfigure memoir and hyperref together

Is it possible to use memoir class with sucaption package? I tried dissemulating the ccaption packages but it doesn't work.

\DisemulatePackage{ccaption}

\documentclass[a4paper,12pt,fleqn,openany]{memoir}

\usepackage{caption}
\usepackage{subcaption}
\begin{document}

\begin{figure}
\begin{subfigure}[b]{.5\linewidth}
\centering\large A
\caption{A subfigure}\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering\large B
\caption{Another subfigure}\label{fig:1b}
\end{subfigure}
\caption{A figure}\label{fig:1}
\end{figure}

\end{document}


I get the following error

LaTeX Error: Command \subcaption already defined.

LaTeX Error: Command \subfloat already defined.

any ideas?

## Update

This doesn't work with hyperref... Adding \usepackage{hyperref} leads to compilation errors.

So the new question is, is it possible to use memoir class with sucaption and hyperref packages? Are the 3 packages compatible?

-

Unfortunately the combination of memoir, caption, and hyperref is not fully compatible. (Not true anymore, see Addendum 2011-10-12.)

When the memoir document class detects the caption package it will re-define some macros to full-feed the needs of the caption package; so this combination works fine alone. But when you load the hyperref package, the memoir class loads the memhfixc package additionally which redefines \caption which makes the caption package to enter the fall-back or so called "compatibility mode".

\documentclass{memoir}
\usepackage{caption,hyperref}
\begin{document}
A
\end{document}


causes

Package caption Info: Incompatible package detected (regarding \caption).
(caption)             \caption = \long macro:->\donemaincaptiontrue \m@moldhypcaption .

Package caption Warning: \caption will not be redefined since it's already
(caption)                redefined by a document class or package which is
(caption)                unknown to the caption package.
See the caption package documentation for explanation.


The subcaption package does not work well in "compatibility mode", causing it to behave strange. (The very next version will issue an error message instead.)

My proposal:

1. I will add the redefinition of the memhfixc package to the database of my caption package. This will stop the caption package from operating in compatibility mode.
2. I will ask the current maintainer of the memoir document class if any further adoption is necessary.

So hopefully this issue will be fixed very soon.

P.S.: Sorry for the late answer

A new version of the caption package bundle is finally available on CTAN and as TeXlive update which fixes the hyperref compatibility issue. But one still needs


\let\subcaption\undefined
\let\subfloat\undefined


before loading the subcaption package since the memoir document class is not adapted to the subcaption package (yet).

Finally I have found some time to take a closer look at this issue, and it seems that I was able to adapt the subcaption package for usage with the memoir document class. I'll release it with the upcoming version 3.3 of the caption package.

-
Thank you very much for your efforts. –  pmav99 Sep 4 '11 at 11:47
The issue is finally fixed, at least on the (sub)caption package side. See Addendum 2011-10-12 I just added to my answer. –  Axel Sommerfeldt Oct 12 '11 at 16:23
Thank you very much! –  pmav99 Oct 12 '11 at 20:09
Let me know if there is anything from the memoir side we can do to make caption vs. memoir easier. Eventhough I maintain memoir, I use caption a lot more than I use the memoir interface for captions. –  daleif Oct 13 '11 at 7:51
@daleif: I'll write you an e-mail about that... –  Axel Sommerfeldt Oct 13 '11 at 16:11

try

\let\subcaption\relax
\let\subfloat\relax


\let\captioncaption\caption