[Tex/LaTex] How to keep the paragraph and subsequent image on one page

graphicspage-breakingparagraphs

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?

Best Answer

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

Related Question