# Wrong spacing before theorem environment (amsthm)

I am using the amsthm package to have environment. I also use \usepackage[onehalfspacing]{setspace} to have 1.5 line spacing.

However, when I use the the theorem environment, the spacing before is not done correctly. It gives me a normal line spacing instead of the 1.5-line spacing. Lets say I have:

First paragraph

Second paragraph

Third paragraph

\begin{theorem} Bla bla. \end{theorem}


I get something like this:

First paragraph

Second paragraph

Third paragraph
Theorem 1. Bla bla.

Do you know how I can change this?

-

## migrated from stackoverflow.comAug 9 '11 at 21:54

This question came from our site for professional and enthusiast programmers.

I actually found out the answer to my question by going the ECM route.

What was causing the problem was that I was using the parskip package with the option parfill, so that paragraphs, instead of starting with a blank indent, would start with no indent but separated by a blank line. ECM:

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem} % <-- Note this line?
\usepackage[onehalfspacing]{setspace}
\usepackage[parfill]{parskip}
\begin{document}
First paragraph

Second paragraph

Third paragraph
\begin{theorem}
1+1=2
\end{theorem}

\end{document}


I found out that I wasn't the first one to have the problem. The solution is to add:

\begingroup
\makeatletter
\@for\theoremstyle:=definition,remark,plain\do{%
}%
}
\endgroup


in the preamble after calling the amsthm package. It will redefine the theorems environment (or any user-defined environment) by adding the warranted extra space at the beginning. The extra space is not hard-coded , so if you remove the parskip package from your preamble, everything returns to the default spacing: nice!

Hope this helps!

-

I used the following file (test.tex)...

\documentclass{article}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem} % <-- Note this line?
\usepackage[onehalfspacing]{setspace}
\begin{document}
First paragraph

Second paragraph

Third paragraph
\begin{theorem}
1+1=2
\end{theorem}

\end{document}


...and then ran

latex test.tex


to get a file test.dvi. All spacing was as it should be above and below the theorem environment

-
Sorry I lost my good habits of ECM... Will try to replicate (or not) the bug this evening! –  Peutch Aug 11 '11 at 17:27