6

Possible Duplicate:
Unbreakable block

I have quite small article section like:

\subsubsection Some title

some text about figure:

\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?

2
  • 2
    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
    Commented Apr 6, 2012 at 7:08
  • that (without figure) was my initial code and the result was the same :(
    – Qrilka
    Commented Apr 6, 2012 at 7:12

1 Answer 1

7

Try

\begin{samepage}
  some text about figure:
  \begin{center}
    \includegraphics[width=0.5\columnwidth]{image-here.png}
  \end{center}
\end{samepage}

The section should not allow breaking after it anyway.

4
  • Maybe 'subsub' (section nesting level) could play role here? Nonethless samepage works like a charm, thanks
    – Qrilka
    Commented Apr 6, 2012 at 8:21
  • 1
    Usually you should use \centering and not center for images. center adds vertical spacing before and afterwards. Commented Apr 6, 2012 at 9:04
  • @Qrilka No, every sectioning command prevents page breaking immediately after it. Commented Apr 6, 2012 at 9:06
  • @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". Commented Apr 6, 2012 at 9:08

Not the answer you're looking for? Browse other questions tagged .