# How do I prevent pagebreak in some piece of text? [duplicate]

Possible Duplicate:
Unbreakable block

I have quite small article section like:

\subsubsection Some title

\begin{figure}[h]
\centering
\includegraphics[width=0.5\columnwidth]{image-here.png}
\end{figure}


I think it would be much better if all those 3 "lines" (title, text and image) will come on single page but I did not find any way to do it except inserting \pagebreak before \subsubsection. I thought \nopagebreak could solve this task but I could not get the desired effect. Is there any other option?

-

## marked as duplicate by lockstep, Stefan Kottwitz♦May 17 '12 at 10:49

The first thing you need to do is remove the \includegraphics from the figure environment, since that is floating (and doesn't remain in the place you specify generally). There is no need to place images inside a figure environment, unless you have a \caption. Even then there are ways around it. –  Werner Apr 6 '12 at 7:08
that (without figure) was my initial code and the result was the same :( –  Qrilka Apr 6 '12 at 7:12

Try

\begin{samepage}

Usually you should use \centering and not center for images. center adds vertical spacing before and afterwards. –  Martin Scharrer Apr 6 '12 at 9:04
@MartinScharrer Well the best would probably be to use some ready made "here figure" macro which will certainly also add vertical space, as figure does when it is placed "here". –  Stephan Lehmke Apr 6 '12 at 9:08