5

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)
  {\bfseries\large} % HEADFONT
  {.}         % HEADPUNCT
  {\newline} % HEADSPACE
  {}          % CUSTOM-HEAD-SPEC

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)
  {\bfseries\large} % HEADFONT
  {.}         % HEADPUNCT
  {\newline} % HEADSPACE
  {}          % CUSTOM-HEAD-SPEC

\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.

nahema
  • 53

1 Answers1

3

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
\newcommand\myonlynewline{\newline\@afterheading}
\makeatother
\newtheoremstyle{teo}
  {15pt}   % ABOVESPACE
  {}   % BELOWSPACE
  {\itshape}  % BODYFONT
  {0pt}       % INDENT (empty value is the same as 0pt)
  {\bfseries\large} % HEADFONT
  {}         % HEADPUNCT
  {5pt plus 1pt minus 1pt} % HEADSPACE
  {\thmname{#1}\thmnumber{ #2}.\normalfont\thmnote{ (#3)}\myonlynewline}  % CUSTOM-HEAD-SPEC

\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}

enter image description here

StefanH
  • 13,823