# How to put a figure inside a minipage when using memoir?

I need to put a figure inside a minipage, like so:

\documentclass{memoir}

\begin{document}
\begin{minipage}{10cm}
\begin{figure}
blabla
\caption{test}
\end{figure}
\end{minipage}
\end{document}


However, LaTeX doesn't like that since it is no longer in outer par mode, so it crashes and burns. I then tried the solution provided here, but that doesn't work either since the float package doesn't play nicely with memoir.

Is there a way of working around this?

• Reversing the order of minipage and figure is not a good option? – karlkoeller Aug 30 '13 at 15:25
• why do you think you want to put a figure in the minipage? Either use minipage (you can use caption from capt-of package) or use figure, you can not use both. – David Carlisle Aug 30 '13 at 15:26
• – user11232 Aug 30 '13 at 22:54

You cannot place a floating environment inside a minipage; if you want to place a caption for your image inside a minipage, you can use memoir's \newfixedcaption command which provides captions outside floating environments:

\documentclass{memoir}
\newfixedcaption{\figcaption}{figure}

\begin{document}

\noindent\begin{minipage}{10cm}
\centering
A
\figcaption{test}
\end{minipage}

\end{document}


Another option would be to use \captionof from the capt-of package:

\documentclass{memoir}
\usepackage{capt-of}

\begin{document}

\noindent\begin{minipage}{10cm}
\centering
A
\captionof{figure}{test}
\end{minipage}

\end{document}


The caption package also provides the \captionof functionality, but it might interfer with the way memoir handles its captions, so I opted for capt-of.

• memoir also have stationary captions, but it is not enabled by default, see \newfixedcaption in the memoir manual – daleif Aug 30 '13 at 15:33
• @daleif I thought I had seen this, but couldn't remember the name. I'll add this to my answer. Thanks! – Gonzalo Medina Aug 30 '13 at 15:35
• I had to look it up ... – daleif Aug 30 '13 at 15:44