[Tex/LaTex] Spacing before and after with \newtheoremstyle

spacingtheorems

I want to define my own theorem style for examples. I want them to be numbered the same way as theorems (so Example 2.4 follows Theorem 2.3); I want them to be formatted exactly the same as theorems except I don't want the text to be in italics.

Here is the current solution my research has given me:

\newtheorem{thm}{Theorem}[chapter]

\newtheoremstyle{exampstyle}
{3pt} % Space above
{3pt} % Space below
{} % Body font
{} % Indent amount
{\bfseries} % Theorem head font
{.} % Punctuation after theorem head
{.5em} % Space after theorem head
{} % Theorem head spec (can be left empty, meaning `normal')

\theoremstyle{exampstyle} \newtheorem{examp}[thm]{Example}

The examp format does everything I need, except that there is no line-spacing before and after each example (whereas there is spacing before and after theorems).

Best Answer

The default spacing above and below the plain theorem style (used in your thm theorem) is \topsep, which is larger than 3pt. Use \topsep in your examp theorem environment to achieve a similar spacing to that of thm.

enter image description here

\documentclass{book}
\usepackage{amsthm}% http://ctan.org/pkg/amsthm

\newtheorem{thm}{Theorem}[chapter]

\newtheoremstyle{exampstyle}
  {\topsep} % Space above
  {\topsep} % Space below
  {} % Body font
  {} % Indent amount
  {\bfseries} % Theorem head font
  {.} % Punctuation after theorem head
  {.5em} % Space after theorem head
  {} % Theorem head spec (can be left empty, meaning `normal')

\theoremstyle{exampstyle} \newtheorem{examp}[thm]{Example}

\begin{document}

Here is some text that is placed above the theorem.

\begin{thm} This is a theorem. \end{thm}

Here is some text that is placed below the theorem.
Here is some text that is placed above the example.

\begin{examp} This is an example.​ \end{examp}

Here is some text that is placed below the example.

\end{document}​​​​​​​​​​​​​​​

\topsep is defined as the length 8.0pt plus 2.0pt minus 4.0pt which is 8pt plus/minus some stretchability (could be anything from 4pt to 10pt), depending on the placement within the context of the page. Of course, you can change this (currently set at 3pt in your code) to whatever, to modify the separation from other document elements.