如何在 tcolorbox 定理周围添加空间

如何在 tcolorbox 定理周围添加空间

amsthm可以轻松更改定理前后的空间。这可以用tcolorbox 定理来实现吗?如果可以,怎么做?我在文档中找不到任何内容。

最小示例:

\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}

答案1

before skipafter skip提供这样的空间。如果空间太小,你就不会注意到它们。

示例输出

\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}

答案2

beforeafter选项对您有用吗?它们在章节中进行了解释4.15 融入周围环境,第 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}

在此处输入图片描述

相关内容