# No page break before a heading, while preserving some vertical space before heading?

How can I prevent a page break before a run-in section heading while preserving vertical spacing before the heading?

Based on the suggestion in How to prevent a page break before an itemize list?, I have defined a run-in heading as

\makeatletter
\newcommand{\runinheading}{\@startsection{paragraph}{4}{\z@}%
{2.1ex \@plus1ex \@minus 0.64ex}{-1em}%
{\sffamily\normalsize\bfseries}}
\newcommand{\nobreakruninheading}{\par\nobreak\@afterheading\runinheading}
\makeatother


I use this heading in the following way:

..., but the process assignment is still in bijective
correspondence with the proof rules.

\nobreakruninheading*{Cut reduction as computation.}
The principal cut reduction is
\begin{equation*}
\text{several lines of math go here}
\end{equation*}
When annotated according to the process interpretation,
we can extract the process reduction


Indeed, LaTeX does not insert a page break before the run-in heading. However, there is no vertical space between the end of the paragraph (... with the proof rules.) and the run-in heading.

I do know that there is enough room on the page with 1.6ex of vertical space prior to the heading because if I instead define \nobreakruninheading* as \vspace{1.6ex}\noindent{\sffamily\normalsize\bfseries #1}\hspace{1em}, everything fits the way I want. I'd like to avoid resorting to this alternate definition, if possible, because it does not match the other section headings in my paper (which use \@startsection).

-

## 1 Answer

My feeling is that if you want vertical space before the runin heading, then a page break is good as well.

Anyway, you get what you ask by adding the spacing after \nobreak:

\makeatletter
\newcommand{\runinheading}{\@startsection{paragraph}{4}{\z@}%
{2.1ex \@plus1ex \@minus 0.64ex}{-1em}%
{\sffamily\normalsize\bfseries}}
\newcommand{\nobreakruninheading}{\par\nobreak\vskip\bigskipamount\@afterheading\runinheading}
\makeatother

-
I would certainly agree that normally a page break should be good as well. This is for a conference submission, though, and space is very tight; it seems that a page break here is the critical point that pushes the paper over the page limit. I wish I didn't have to resort to this kind of hackery... –  Henry DeYoung Jun 27 '12 at 17:08
Your solution is just the ticket; thanks! –  Henry DeYoung Jun 27 '12 at 17:20