# Avoiding pagebreak after newline in theorem

This might be of relevance:

## Situation

I used the information provided in this answer to come up with this break-style:

\newtheoremstyle{break}
{2em} %spaceabove
{} %spacebelow
{} %\itshape} %bodyfont
{-1em} %indentamt
{
\thmnumber{#2}\thmname{ #1}%
\thmnote{ (#3) }


Note that I have no control over where my theorems are going to be placed, as they are imported into a main file and a compendium (using this method).

## Attempts

Moreover I tried to put \unskip\pagebreak (from here (2.)) behind \newline in headspace as well as behind (#3) in headspec. This, however, achieved the opposite: pagebreaks after each theorem header.

Unfortunately I do not have enough insight in LaTeX to adapt this (3.) to my needs. It will produce crammed pages with peculiar indentation on some theorems and alike, plus, it does not completely fix the problem (I got at least 1 instance of the very same problem in my compendium).

# How to avoid a page-break after the theorem-title when using my own theoremstyle that breaks the line.

## Update:

1. after try out alexraasch suggestion

\nobreak produces widows and orphans (at least title + first line) instead of breaking beforehand.
Plus I do use \newcommand{\spaceBeforeEnumOnly}{~\vspace{-1em}} in case a theorem or alike only consists of nothing but an enumeration - adding \nobreak did not work here.

Personally I think this is rather unaesthetic, but LaTeX probably doesn't even recognize those as unpleasing. The first one appears more often and also in combination with the aforementioned \spaceBeforeEnumOnly.
• Try adding \breakpenalty=10000 or \nobreak in the headspec. – alexraasch Mar 12 '16 at 14:48
• @alexraasch, \breakpenalty=10000 produces an error. \nobreak does have some impact, though it produces widows and orphans (at least title + first line) instead of breaking beforehand. Plus I do use \newcommand{\spaceBeforeEnumOnly}{~\vspace{-1em}} in case a theorem or alike only consists of nothing but a enumeration - adding \nobreak did not work here. – BadAtLaTeXProgramming Mar 12 '16 at 15:08
• Ahm, well, I have to do a little guess work. You could also try to keep \nobreak in the headspec and add \widowpenalty=5000 and \clubpenalty=5000 to your document. If that doesn't work set these penalties to 10000. – alexraasch Mar 12 '16 at 15:25