# How to keep the paragraph and subsequent image on one page?

I have a text, where pictures are interleaved with descriptions for them. And since pictures are quite big, sometimes picture moves to next page, but the description for it stays on the previous page, which is ugly.

The code:

Some description for the following image:
\begin{center}
\includegraphics[width=\textwidth]{../path/to/image.png}
\end{center}


I tried using \nopagebreak, but LaTeX just ignored me. And using samepage also did not help - it started to pull the text from under the previous image down the page.

What can I do to keep the description and the image on the same page?

-

If you know the height of the image, you might try the needspace package and say \Needspace{the height you need} before the image.

-
Needspace looks good. But it is really scary - what if I change the size of an image and forget to update the \needspace declaration? –  Rogach Mar 28 '12 at 0:19
@Rogach, in that case, you might try David Carlisle's solution instead -- it's more robust. –  Ben Lerner Mar 28 '12 at 1:09
\noindent\begin{minipage}{\textwidth}
Some description for the following image:
\begin{center}
\includegraphics[width=\textwidth]{../path/to/image.png}
\end{center}
\end{minipage}


makes an indivisible box that will never break.

-