Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Aug 9 '11 at 21:54

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

2 Answers 2

up vote 10 down vote accepted

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{%
        \expandafter\g@addto@macro\csname th@\theoremstyle\endcsname{%
            \addtolength\thm@preskip\parskip
            }%
        }
\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!

share|improve this answer

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

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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