# Prevent Page Break between glossary heading and first entry

I use the glossaries package to define some abbreviations and terms. I also created my own style (not really necessary in the MWE, but in my complete document I want to show more information). The problem is that I'm not able to prevent a page break between the header of the glossary and the first entry. I already tried to introduce \nopagebreak at several locations but didn't succeed.

% arara: lualatex: { synctex: on }
% arara: makeglossaries
% arara: lualatex: { synctex: on }
% arara: lualatex: { synctex: on }

\documentclass[]{article}

\usepackage[nonumberlist,nopostdot,nogroupskip,savewrites]{glossaries}

\newglossarystyle{myGlossaryStyle}{%
\renewenvironment{theglossary}%
{\begin{longtable}{p{0.125\textwidth}p{0.875\textwidth}}}{\end{longtable}}%
\renewcommand{\glossentry}[2]{      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & \glossentrydesc{##1} \tabularnewline}
\renewcommand{\subglossentry}[3]{\glossentry{##2}{##3}}%
}

\newglossary*{glo1}{Glossary 1}
\newglossary*{glo2}{Glossary 2}
\makeglossaries

\newglossaryentry{e1}{name={e1}, description={e1 with a very very long line such that it needs at least two lines, which even needs some more words}}
\newglossaryentry{e2}{name={e2}, description={e2 with a very very long line such that it needs at least two lines, which even needs some more words}}
\newglossaryentry{e3}{name={e3}, description={e3}}
\newglossaryentry{e4}{name={e4}, description={e4}}
\newglossaryentry{e5}{name={e5}, description={e5}}
\newglossaryentry{e6}{name={e6}, description={e6}}
\newglossaryentry{e7}{name={e7}, description={e7}}
\newglossaryentry{e8}{name={e8}, description={e8}}
\newglossaryentry{e9}{name={e9}, description={e9}}
\newglossaryentry{e10}{name={e10}, description={e10}}

\newglossaryentry{glo1-e1}{name={glo1-e1}, description={glo1-e1 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e2}{name={glo1-e2}, description={glo1-e2 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e3}{name={glo1-e3}, description={glo1-e3 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e4}{name={glo1-e4}, description={glo1-e4 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e5}{name={glo1-e5}, description={glo1-e5 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e6}{name={glo1-e6}, description={glo1-e6 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e7}{name={glo1-e7}, description={glo1-e7 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e8}{name={glo1-e8}, description={glo1-e8 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e9}{name={glo1-e9}, description={glo1-e9 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo1}}
\newglossaryentry{glo1-e10}{name={glo1-e10}, description={glo1-e10}, type={glo1}}

\newglossaryentry{glo2-e1}{name={glo2-e1}, description={glo2-e1 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo2}}
\newglossaryentry{glo2-e2}{name={glo2-e2}, description={glo2-e2 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo2}}
\newglossaryentry{glo2-e3}{name={glo2-e3}, description={glo2-e3 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo2}}
\newglossaryentry{glo2-e4}{name={glo2-e4}, description={glo2-e4 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo2}}
\newglossaryentry{glo2-e5}{name={glo2-e5}, description={glo2-e5}, type={glo2}}
\newglossaryentry{glo2-e6}{name={glo2-e6}, description={glo2-e6}, type={glo2}}
\newglossaryentry{glo2-e7}{name={glo2-e7}, description={glo2-e7}, type={glo2}}
\newglossaryentry{glo2-e8}{name={glo2-e8}, description={glo2-e8 with a very very long line such that it needs at least two lines, which even needs some more words}, type={glo2}}
\newglossaryentry{glo2-e9}{name={glo2-e9}, description={glo2-e9}, type={glo2}}
\newglossaryentry{glo2-e10}{name={glo2-e10}, description={glo2-e10}, type={glo2}}

\begin{document}
\setglossarysection{section}
\printglossary[type=glo1, style=myGlossaryStyle]
\printglossary[type=glo2, style=myGlossaryStyle]
\printglossary[type=main, title={Main Glossary}, style=myGlossaryStyle]
\end{document}


• Could you make this MWE compilable? I get quite a few errors with your code. – schtandard Aug 13 at 5:41

\begin{document}