13

Is there a way to change the vertical space before/after theorem environments, without defining a new theorem style? I'm using amsthm package to define my new theorem environments.

Sigur
  • 37,330

1 Answers1

10

Without defining new theorem styles, you can modify the macro that's used by default, which is \thm@space@setup

\documentclass{article}
\usepackage{amsthm,lipsum}
\makeatletter
\def\thm@space@setup{%
  \thm@preskip=5cm plus 1cm minus 2cm
  \thm@postskip=\thm@preskip % or whatever, if you don't want them to be equal
}
\makeatother

\newtheorem{thm}{Theorem}

\begin{document}
\lipsum[2]

\begin{thm}
$1+1=2$
\end{thm}

\lipsum[2]

\end{document}

The default value is \topsep. You don't need to have the same space above and below the theorem.

egreg
  • 1,121,712
  • Ha! Perfect!! Thanks so much. Just one question: is \topsep used only by this macro? May I change only its value? – Sigur Dec 03 '12 at 22:24
  • 1
    @Sigur \topsep is the parameter normally used by list environments (enumerate, itemize and description); I would change neither the spacing around theorems nor \topsep, for what it's worth. :) – egreg Dec 03 '12 at 22:25
  • @egreg, neither around theorems! Why? Should I use rubber length? – Sigur Dec 03 '12 at 22:27
  • 1
    @Sigur \topsep is a rubber length. It's default value in the standard classes is 8pt plus 2pt minus 4pt (at 10pt size) or 10pt plus 4pt minus 6pt (at 12pt size). I believe it's a good compromise: not larger than the baseline skip (at least in its natural length), but flexible enough. Theorems already have a header that, together with the spacing, makes them prominent enough. – egreg Dec 03 '12 at 22:32
  • OK. I see. You added the rubber space on the answer. Thanks. I'll accept it. – Sigur Dec 03 '12 at 22:35
  • 1
    Is there a way to adjust the two parameters locally? – Argyll May 30 '16 at 09:55
  • @Argyll What do you mean? – egreg May 30 '16 at 09:56
  • 1
    Is there a way to modify the before/after environment spacing for a single instance? – Argyll May 30 '16 at 09:56
  • @egreg Thank you for your super fast response as always!! – Argyll May 30 '16 at 09:56
  • @Argyll \begingroup\setlength{\topsep}{100pt}\begin{thm}...\end{thm}\endgroup – egreg May 30 '16 at 10:26
  • But in this case, isn't the preskip and postskip parameters already set to something other than \topsep? – Argyll May 30 '16 at 10:36
  • And to clarify, even though I would be curious of how to adjust spacing for theorem environments, I am actually stuck with extra spacing for the proof environment. The global solution for proof was addressed by you in http://tex.stackexchange.com/questions/49801/how-can-i-eliminate-the-vertical-extra-space-before-and-after-the-proof-environm – Argyll May 30 '16 at 10:38