Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 10 down vote accepted

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.

share|improve this answer
    
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

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
share|improve this answer
    
it worked thank you –  pmav99 May 24 '11 at 10:36
    
@ 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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