# Prevent page break after a subsection

Although page breaks are typically not allowed after \subsection commands, I am running into one with the ExPex package. If anyone knows that package specifically, a specific question would be welcome. I'm also interested in any more general solution, however, which would perhaps cover many cases where I'm not sure what's in the macro.

For the time being I am putting everything in a minipage; it feels like there should be a better way to do it, though.

\documentclass[10pt]{book}
\usepackage{expex,lipsum}
\begin{document}
\lipsum[1-4]\lipsum[4]
\ex
\begingl
\gla Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam consectetuer mollis dolor. Quisque malesuada nulla sed pede volutpat pulvinar. Aliquam metus. Morbi turpis arcu, egestas congue, condimentum quis, tristique cursus, leo. //
\endgl
\xe
\end{document}


From the documentation: "\exbreak is inserted at the beginning of every \ex or \pex block.". \exbreak inserts a penalty which tells TeX that here is a good place to break. You could redefine this penalty (locally or for ever, its default value is -50):

\documentclass[10pt]{book}
\usepackage{expex}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]\lipsum[4]
\renewcommand\lingexbreakpenalty{10000}

\ex
\begingl
\gla Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nam consectetuer mollis dolor. Quisque malesuada nulla sed pede volutpat pulvinar. Aliquam metus. Morbi turpis arcu, egestas congue, condimentum quis, tristique cursus, leo. //
\endgl
\xe
\end{document}


I have no experience with the ExPex package, but \ex add 2.7ex plus .4ex minus .4ex above the item, so it seem that LaTeX find a good place to a page break here.

One solution that comes to my head is start the section (fisrt paragraph) with a empty box, for example \hbox{}, and then use the option aboveexskip to reduce the extra space to 0pt:

\documentclass[10pt]{book}
\usepackage{expex,lipsum}
\begin{document}
\lipsum[1-4]\lipsum[4]