1

On the question How to create a box with caption and label like a float?, they teach how to create your own caption with the caption package command \DeclareCaptionType, but it not seems to be working with memoir class: memoir class with subcaption and hyperref packages

Then I tried loading \usepackage{capt-of} instead of caption:

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{capt-of}
\usepackage{graphicx,newfloat}

\DeclareCaptionType{InfoBox}

\begin{document}

    \fboxsep=8pt\relax
    \fboxrule=2pt\relax
    \begin{center}
    \fbox{\centering
      \includegraphics[width=2in]{example-image-A}}\par
      \captionof{InfoBox}{Here is my caption\label{fg:A}}
    \end{center}

    \begin{InfoBox}[ht]
    \centering
    \fbox{\centering\medskip
      \includegraphics[width=2in]{example-image-B}}\par
      \caption{Here is my caption\label{fg:B}}
    \end{InfoBox}

\end{document}

But still creating errors:

test3.tex:9: Undefined control sequence 
Here is how much of TeX's memory you used:
...

On line 14 there is the \DeclareCaptionType command for the caption package. How can it be used with the memoir class?

| improve this question | | | | |
  • The caption package works for me, as well with hyperref, the linked question about the memoir, caption, hyperref - Problem has an addendum by Axel Sommerfeldt, the author of caption, that this problem has gone. – user31729 Sep 18 '17 at 13:54
  • But when I load both of them, I still got a big warning: Class memoir Warning: You are using the caption package with the memoir class. To prepare we will now reset all captioning macros and configurations to kernel defaults, and then let the caption package take over. Please remember to use the caption package interfaces in order to configure your captions. Why show such thing every time I build my document? I can just silence this strange text? – user Sep 18 '17 at 13:57
  • It is a Warning, nothing more or less. caption is meant to improve ... captions ;-) – user31729 Sep 18 '17 at 13:59
  • Well, it is only warning I have on my document. I never had to silence any warnings before, I just fixed whatever they were complaining about. So how I can fix whatever this new warning is complaining about? – user Sep 18 '17 at 14:09
  • You can only do if you would change the memoir code. Don't do that. Just live with the warning... – user31729 Sep 18 '17 at 14:15
1

Based on the questions:

  1. Table of code listings
  2. How to silence memoir class warning against the use of caption package?
  3. How to create a box with caption and label like a float?

You can use the following code for suppressing the warning, as the warning is only documentation on how to use the memoir's class, instead of something you should be fixing.

Class memoir Warning: You are using the caption package with the memoir class. To prepare we will now reset all captioning macros and configurations to kernel defaults, and then let the caption package take over. Please remember to use the caption package interfaces in order to configure your captions.

Noticing know on you need to ignore the caption documentation from the memoir's class and use the caption documentation from the caption package.

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage{silence}
\WarningFilter*{memoir}{You are using the caption package with the memoir class}

\usepackage{caption}
\DeclareCaptionType{code}[Code Listing][List of Code Listings]

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{capt-of}
\usepackage{listings}

\begin{document}

\listofcodes

    \begin{code}
        \begin{lstlisting}
            Some source code
        \end{lstlisting}
        \caption[This here is a caption]{caption}
    \end{code}

\end{document}

enter image description here

| improve this answer | | | | |

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.