1

The following source uses the \tcolorboxenvironment{theorem} environment (from the tcolorbox package) to shade the background of the theorem environment, where thmtools has been used to define the theorem style.

How can the space above and below that environment — so that it is the same as for the proposition environment (which uses the same theoremstyle)?

\documentclass{memoir}
\usepackage{newtxtext}
\usepackage[dvipsnames]{xcolor}
\usepackage[theorems]{tcolorbox}
\usepackage{amsthm}
\usepackage{thmtools}
\swapnumbers

\makeatletter
\declaretheoremstyle[
  headfont= \sffamily\bfseries\color{cyan!50!black},
  headpunct={\sffamily\bfseries.},
  postheadspace=0.5em,
  notefont=\sffamily\bfseries,
  headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
  bodyfont=\mdseries\slshape,
  spaceabove=12pt,spacebelow=12pt,
  % trying color shading but does nothing ??
  %shaded={bgcolor=mythmback},
]{thmstyle}
\makeatother

\theoremstyle{thmstyle}
\declaretheorem[name=Theorem,numberwithin=chapter]{theorem}
\newtheorem{proposition}[theorem]{Proposition}

% For colored boxes
\definecolor{lightcyan}{rgb}{0.88, 1.0, 1.0}
\colorlet{mythmback}{lightcyan!40!white}

\tcolorboxenvironment{theorem}{%
colback=mythmback,coltitle=blue,colframe=mythmback,
left=0pt,right=0pt,
% next 2 keys just change spacing above, below text within_ the frame, not above, below environment
top=0pt,bottom=0pt,}

\usepackage{kantlipsum}

\begin{document}

\chapter{Chapter One}
\section{The section}
\kant[1]

\begin{theorem}
The square on the hypotenuse of a right triangle equals the sum of the squares of the hypotenuses on the other two sides.
\end{theorem}
\kant[2]

\begin{proposition}
A set is infinite if and only if it has a proper subset that can be put into one-to-one correspondence with the entire set.
\end{proposition}

\kant[3]

\end{document}

Insufficient spacing above and below boxed theorem

Why did I use \tcolorboxenvironment instead of just \newtcbtheorem? Because I need the full power of thmtools for various purposes not indicated here.

What I tried

  • In \tcolorboxenvironment{theorem}, to change the last two keys to top=12pt,bottom=12pt. However, this just changes the amount of space above and below the text within the box, not the space of the box from the (kantsum) text above and below the box.
  • Instead of using tcolorbox, adding within the \declaretheoremstyle the additional key shaded=bgcolor=mythmback}, but this seems to have no effect whatsoever.
3
  • 3
    You can use for instance before skip=10pt, after skip=10pt in the ... argument of your \tcolorboxenvironment{theorem}{...} call.
    – frougon
    Commented May 11, 2020 at 22:35
  • @frougon: Perfect, thank you! (Is the "moral" here that any option that can be used for \tcbset or \tcolorbox can be used for \tcoloorenvironent?)
    – murray
    Commented May 12, 2020 at 0:32
  • All options allowed in the optional argument of the tcolorbox environment should be fine.
    – frougon
    Commented May 12, 2020 at 7:30

1 Answer 1

6

The space above and below the tcolorbox can be controlled with before skip and after skip, for instance:

\tcolorboxenvironment{theorem}{
  colback=mythmback,coltitle=blue,colframe=mythmback,
  left=0pt,right=0pt,
  top=0pt,bottom=0pt,
  before skip=10pt, after skip=10pt,
}

As far as I know, all options allowed in the optional argument of the tcolorbox environment should be fine to use in the second argument of \tcolorboxenvironment.

Full code:

\documentclass{report}
\usepackage{tcolorbox}
\usepackage{amsthm}
\usepackage{thmtools}
\swapnumbers

\makeatletter
\declaretheoremstyle[
  headfont= \sffamily\bfseries\color{cyan!50!black},
  headpunct={\sffamily\bfseries.},
  postheadspace=0.5em,
  notefont=\sffamily\bfseries,
  headformat=\NAME\NUMBER\let\thmt@space\@empty\NOTE,
  bodyfont=\mdseries\slshape,
  spaceabove=12pt,spacebelow=12pt,
  % trying color shading but does nothing ??
  %shaded={bgcolor=mythmback},
]{thmstyle}
\makeatother

\theoremstyle{thmstyle}
\declaretheorem[name=Theorem,numberwithin=chapter]{theorem}
\newtheorem{proposition}[theorem]{Proposition}

% For colored boxes
\definecolor{lightcyan}{rgb}{0.88, 1.0, 1.0}
\colorlet{mythmback}{lightcyan!40!white}

\tcolorboxenvironment{theorem}{
  colback=mythmback,coltitle=blue,colframe=mythmback,
  left=0pt,right=0pt,
  top=0pt,bottom=0pt,
  before skip=10pt, after skip=10pt,
}

\usepackage{kantlipsum}

\begin{document}

\chapter{Chapter One}
\section{The section}
\kant[1]

\begin{theorem}
The square on the hypotenuse of a right triangle equals the sum of the squares of the hypotenuses on the other two sides.
\end{theorem}
\kant[2]

\begin{proposition}
A set is infinite if and only if it has a proper subset that can be put into one-to-one correspondence with the entire set.
\end{proposition}

\kant[3]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .