[Tex/LaTex] Local \theorempreskipamount and \theorempostskipamount of ntheorem

ntheoremspacing

It seems that \theorempreskipamount and \theorempostskipamount cannot be set locally meaning that they will keep the same value for all the defined environments even though the user may wish different values for theorems, definitions or proofs. Is there a work around to avoid that?

Best Answer

Using, for example, \theoremprework you can set those lengths for particular groups of theorem-like structures:

\documentclass{scrreprt}
\usepackage{ntheorem}
\usepackage{lipsum}   

\theoremprework{%
\setlength\theorempreskipamount{1ex}\setlength\theorempostskipamount{1ex}
}
\newtheorem{defi}{Definition}
\theoremprework{%
\setlength\theorempreskipamount{1cm}\setlength\theorempostskipamount{1cm}
}
\newtheorem{theo}{Theorem}

\begin{document}
\lipsum[1]
\begin{defi}
test
\end{defi}    
\lipsum[1]
\begin{theo}
test
\end{theo}    
\lipsum[1]

\end{document}

enter image description here

Using the thmtools front-end, you can define custom styles with their own values for spaceabove, spacebelow:

\documentclass{scrreprt}
\usepackage{ntheorem}
\usepackage{thmtools}
\usepackage{lipsum}   

\declaretheoremstyle[spaceabove=1ex, spacebelow=1ex]{styleone}
\declaretheorem[style=styleone]{theorem}
\declaretheoremstyle[spaceabove=1cm, spacebelow=1cm]{styletwo}
\declaretheorem[style=styletwo]{definition}

\begin{document}
\lipsum[1]
\begin{definition}
test
\end{definition}    
\lipsum[1]
\begin{theorem}
test
\end{theorem}    
\lipsum[1]

\end{document}