# How to prevent a pagebreak after the head of custom amsthm enviorement

I have defined a custom amsthm environment for my theorems and such, because I want to have a line break after the header.

\newtheoremstyle{teo}
{15pt}   % ABOVESPACE
{}   % BELOWSPACE
{\itshape}  % BODYFONT
{0pt}       % INDENT (empty value is the same as 0pt)


Is there any way to prevent LaTeX from putting a page break in between the header and body of my theorems? The \nopagebreak command does not seem to work for me.

If I put it into my custom environment definition, it just produces errors and if I insert it into an instance of the environment itself it seems to do nothing.

Edit: This produces an example of the behavior I want to avoid:

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,english]{babel}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum}
\newtheoremstyle{teo}
{15pt}   % ABOVESPACE
{}   % BELOWSPACE
{\itshape}  % BODYFONT
{0pt}       % INDENT (empty value is the same as 0pt)

\theoremstyle{teo}
\newtheorem{defi}{Definition}[section]

\begin{document}
\section{test}
\lipsum[1-3]
\vspace{90px}
\lipsum[4]
\begin{defi}[Derivative Operator Monoid]
Let $(R,\Delta)$ be a differential ring. We define: \dots
\end{defi}
\end{document}


Edit2: Added the missing document class line.

• can you provide a small example document? – David Carlisle Mar 9 '17 at 13:52
• I added compilable example code. – nahema Mar 9 '17 at 14:19
• Please make the code complete, we also need information about the document class (as some configure things differently than others) – daleif Mar 9 '17 at 14:21

You can modify the theorem head in the last argument, but then you also have to do all of it. Here is an alternative where \@afterheading is used to prevent the page break:

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,english]{babel}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{lipsum}

\makeatletter
\makeatother
\newtheoremstyle{teo}
{15pt}   % ABOVESPACE
{}   % BELOWSPACE
{\itshape}  % BODYFONT
{0pt}       % INDENT (empty value is the same as 0pt)
{5pt plus 1pt minus 1pt} % HEADSPACE

\theoremstyle{teo}
\newtheorem{defi}{Definition}[section]

\begin{document}
\section{test}
\lipsum[1-3]
\vspace{90px}
\lipsum[4]
\begin{defi}[Derivative Operator Monoid]
Let $(R,\Delta)$ be a differential ring. We define: $\dots$
\end{defi}
\end{document}