# Force a caption to be on the same page as a figure

I'm using the overpic environment to include figures, and the memoir class to add captions. How do I force the caption to always stay on the same page as its corresponding figure?

Below is my MWE. If the image is big enough, the caption appears on the following page.

\documentclass[11pt,a4paper]{memoir}

\usepackage{fouriernc} % use the Arev font
\usepackage{overpic} % use the overpic package

% caption images outside the figure environment
\newfixedcaption{\figcaption}{figure} \captionnamefont{\normalfont} \captiontitlefont{\normalfont}

\begin{document}

This is some text.

\begin{center}
\begin{overpic}[width=0.9\textwidth]{./myfig.pdf}
\put(10, 10){Here is text superimposed on the figure.}
\end{overpic}
\figcaption{I want this caption on the same page as the corresponding figure.}
\end{center}

\end{document}

-

Since there is no connection between the overpic environment and \figcaption, they can get separated. Also, the center environment doesn't keep things together (in a box, that is), but merely acts as a switch to change the justification of whatever it contained within.

The following should result in the correct behaviour:

\noindent
\begin{minipage}{\textwidth}
\centering
\begin{overpic}[width=\textwidth]{tiger.pdf}
\put(10, 10){Here is text superimposed on the figure.}
\end{overpic}
\figcaption{I want this caption on the same page as the corresponding figure.}
\end{minipage}


It boxes the contents in a minipage of full width (\textwidth), centres the contents (\centering) and avoids a paragraph indent (\noindent) since it is set in horizontal mode (and is therefore considered a paragraph).

It does not, however, avoid overfull boxes from occurring if the contents of the minipage oversteps the text block boundaries.

-