8

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?

13

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

Addendum 2011-10-12

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).

Addendum 2012-04-10

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.

  • 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
  • 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
  • @Axel, I currently see only caption v3.2f on CTAN. Is that v3.3 release expected soon? I don't mean to be pushy, but this is something I'm definitely eager to use. Thank you for any news you can offer! – Ben Liblit Aug 10 '12 at 15:44
  • Version 3.3 of the caption package was finally released in January. Thanks for your patience. – Axel Sommerfeldt Mar 7 '13 at 7:09
4

try

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

before loading those packages

(untested)

as for the hyperref try this (I do not garantee for other problems)

\let\captioncaption\caption
\usepackage{hyperref}
\let\caption\captioncaption
  • @ daleif it works but only when "hyperref" is missing. Any more ideas? thank you – pmav99 May 24 '11 at 12:20
  • @pmav99: Take a look at my (new) answer – Axel Sommerfeldt Sep 4 '11 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.