4

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.

  • 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
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.