阴影定理 (thmtools) 跨越页面

阴影定理 (thmtools) 跨越页面

当使用该thmtools包创建具有阴影背景的定理环境时,它不允许单独的定理跨越多页。如果文档包含许多长定理,一个接一个,这是一个相当严重的问题。这是一个最小的例子。

\documentclass{minimal}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[english]{babel}
\usepackage{blindtext}

\declaretheoremstyle[
    shaded={bgcolor=\color{rgb}{0.9,0.9,0.9}}  % comment this line in/out
]{theorem}
\declaretheorem[style=theorem]{theorem}

\begin{document}

\begin{theorem}
\blindtext[5]
\end{theorem}

\begin{theorem}
\blindtext[5]
\end{theorem}

\end{document}

包括和不包括阴影的情况如下: 坏的好的

如何包含阴影,但允许定理跨越页面?

答案1

您可以\newmdtheoremenvmdframed包中使用一个小示例(根据您的需要更改长度和其他设置):

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{blindtext}

\definecolor{mybg}{rgb}{0.9,0.9,0.9}

\newmdtheoremenv [backgroundcolor=mybg, %
innertopmargin =0pt , %
splittopskip = \topskip, % 
skipbelow= 6pt, %
skipabove=6pt, %
topline=false,bottomline=false,leftline=false,rightline=false,]{theorem}{Theorem}

\begin{document}

\begin{theorem}
\blindtext[5]
\end{theorem}

\begin{theorem}
\blindtext[5]
\end{theorem}

\end{document}

在此处输入图片描述

正如 Ulrich Schwarz 所评论的,您可以使用preheadhookhookspostfoothook形式thmtools来添加mdframed具有所需规格的环境:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[margin=2cm]{geometry}% just for the example
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{mdframed}
\usepackage{blindtext}
\usepackage{thmtools}

\definecolor{mybg}{rgb}{0.9,0.9,0.9}

\declaretheoremstyle[
headfont=\normalfont\bfseries,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont\itshape,
postheadspace=0.5em,
preheadhook={\begin{mdframed}[backgroundcolor=mybg, %
  innertopmargin =0pt , splittopskip = \topskip, % 
  skipbelow= 6pt, skipabove=6pt, %
  topline=false,bottomline=false,leftline=false,rightline=false]},
postfoothook=\end{mdframed}
]{mystyle}
\declaretheorem[style=mystyle]{theorem}

\begin{document}

\begin{theorem}
\blindtext[5]
\end{theorem}

\begin{theorem}
\blindtext[5]
\end{theorem}

\end{document}

相关内容