# Spacing before and after with \newtheoremstyle

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
{.} % 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).

-
Assuming that I load the amsthm package, it works perfectly for me. Can you give a MWE (a full document) showing the problem? – mbork Dec 7 '11 at 16:54

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.

\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
{.} % 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.

-
\topsep is used only for theoremstyle or also for other commands? I'd like to change the vertical space before and after all my theorem environments. Is it possible to change only a variable that controls this space or should I change the whole style? – Sigur Nov 30 '12 at 21:31

if you're using amsthm, there is already a \theoremstyle{definition} that is exactly the same as the plain theorem style except that the text is set in roman. there is also \theoremstyle{remark} that's the same as definition except that it doesn't add extra space above and below. using these three styles, you can keep everything numbered consecutively without having to define anything new:

\theoremstyle{plain} % default
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}


why so many people don't seem to know about the different styles is beyond me. it's right there on p.3 of the amsthm documentation (try texdoc amsthm), including a list of the types of objects usually associated with each style.

update: the amsthm documentation has been thoroughly overhauled, and the description of the three styles provided by default is now on p.7. the new manual is packaged with tex live 2015, and is also available from ctan.

-