19

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?

lockstep
  • 250,273
Peutch
  • 2,182

2 Answers2

23

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!

Peutch
  • 2,182
  • 2
    Thanks, but what does ECM mean? – Travis Bemrose Mar 24 '16 at 06:29
  • 1
    I notice there's still strange spacing with the proof environment. Following this question, I've noticed that \begin{proof} \unskip Content \end{proof} \unskip fixes this. Any chance of filling out this answer to also make the proof environment bulletproof with the parskip package? ;-) – Travis Bemrose Mar 24 '16 at 06:54
  • 2
    ECM = Exemple Complet Minimal, which in English is Minimal Working Example (MWE). – Peutch Apr 12 '17 at 15:38
2

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

Werner
  • 603,163