# How to prevent pagebreaking before example environment?

In my document, the page happens to break right after the line that introduces an example environment:

\documentclass{article}
\usepackage{gb4e}

\begin{document}
\noindent Here are my results:
\begin{exe}
\ex This is my first result.
\ex This is my second result.
\end{exe}
\end{document}


I tried to put Here are my results:\nobreak, as indicated in this answer, but that changed nothing for me. What should I do?

-
Try \makeatletter\@afterheading\makeatother. –  Stephan Lehmke Dec 11 '12 at 20:24
I tried Here are my results:\makeatletter\@afterheading\makeatother, but that didn't work. –  Sverre Dec 11 '12 at 20:25
if you insert \goodbreak before the line "Here are my results:" that would encourage latex to push that line to the next page if it's within a line or two of the bottom of the page, and wouldn't do anything if there's more space than that. not a great approach, but better than a page forced by \newpage. (i didn't go into gb4e, but it's likely that surgery there would be necessary to permit something like \nobreak to be effective.) –  barbara beeton Dec 11 '12 at 20:31
Oops, sorry. I think you need \par \nobreak\makeatletter\@afterheading\makeatother. Sorry for groping in the dark, but your MWE has no page break ;-) –  Stephan Lehmke Dec 11 '12 at 20:35
barbara's \goodbreak works fine. Stephan's latter approach works too, but it also removes the vertical space that's normally above the exe environment. –  Sverre Dec 11 '12 at 20:40

if you insert \goodbreak before the line "Here are my results:" that would encourage latex to push that line to the next page if it's within a line or two of the bottom of the page, and wouldn't do anything if there's more space than that. not a great approach, but better than a page forced by \newpage.
i didn't go into gb4e, but it's likely that surgery there would be necessary to permit something like \nobreak to be effective.