Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer
    
Maybe 'subsub' (section nesting level) could play role here? Nonethless samepage works like a charm, thanks –  Qrilka Apr 6 '12 at 8:21
1  
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
    
@Qrilka No, every sectioning command prevents page breaking immediately after it. –  Stephan Lehmke Apr 6 '12 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". –  Stephan Lehmke Apr 6 '12 at 9:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.