5

In amsthm you can easily change the space before and after a theorem. Can this be done with tcolorbox theorem? If so, how? I haven't been able to find anything in the documentation.

Minimal example:

\documentclass{report}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\newtcbtheorem[number within=section]{mytheo}{My Theorem}
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries}{th}

\begin{document}
Add space below this text.

\begin{mytheo}{This is my title}{theoexample}
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number.
\end{mytheo}

Add space above this text.
\end{document}
  • Can you provide a MWE? ;-) – user31729 Jun 4 '15 at 15:53
  • 2
    It should be possible using \newtcbtheorem -- the options passed to this declaring command will go to the underlying tcolorbox. Something like before skip=0.5in and after skip=0.3in perhaps – user31729 Jun 4 '15 at 15:55
  • @ChristianHupfer I added an MWE. I also tried the options you suggested, but they didn't work. – Randy Randerson Jun 4 '15 at 15:59
7

before skip and after skip provide such spaces. You will not notice them if they are too small.

Sample output

\documentclass{report}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\newtcbtheorem[number within=section]{mytheo}{My Theorem}
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries,before
skip=20pt plus 2pt,after skip=20pt plus 2pt}{th}

\begin{document}
Add space below this text.

\begin{mytheo}{This is my title}{theoexample}
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number.
\end{mytheo}

Add space above this text.
\end{document}
  • For some reason, these options weren't recognized when I tried to use them. Do you know how I can fix that? – Randy Randerson Jun 4 '15 at 17:02
  • What version of the package do you have? If you add \listfiles to your document, the version information will be printed in the .log file. My version is tcolorbox.sty 2015/03/16 version 3.50 – Andrew Swann Jun 4 '15 at 17:06
  • Mine is tcolorbox.sty 2014/05/18 version 3.04, so that explains it. – Randy Randerson Jun 4 '15 at 17:09
  • I try to keep my whole distribution up-to-date, cf. tex.stackexchange.com/q/55437/15925. I am using texlive 2014, awaitng TL2015. – Andrew Swann Jun 4 '15 at 17:12
  • 1
    Good to hear this works. I partly choose this as illustration that it is glue (stretchable space) instead of just a dimension; it means the space will be somewhere between 20pt and 22pt. It is usually a good idea to include some flexibility, particularly if your document is flush bottom (often the default), to give LaTeX some extra freedom in spacing elements on the page. Many standard environments have space with some glue. – Andrew Swann Jun 5 '15 at 8:37
2

Do before and after options serve to you? They are explained in section 4.15 Embedding into the Surroundings, page 75.

\documentclass{report}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\newtcbtheorem[number within=section]{mytheo}{My Theorem}
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries, before={\vspace{2cm}}, after={\vspace{1cm}}}{th}

\begin{document}
Add space below this text.

\begin{mytheo}{This is my title}{theoexample}
This is the text of the theorem. The counter is automatically assigned and,
in this example, prefixed with the section number.
\end{mytheo}

Add space above this text.
\end{document}

enter image description here

  • This solution causes my theorems to be indented. Any idea how to fix it? – Randy Randerson Jun 4 '15 at 17:02
  • Actually, there is no problem with after, only with before. – Randy Randerson Jun 4 '15 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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