现在,我使用thmtools
withmdframed
创建带有边线的定理环境。困难在于我还想能够更改这些定理环境中文本的颜色。问题是使用预期方法(参数\color{}
中的调用bodyfont
)定义此颜色存在错误:它会在分页符处中断。
风格:
\declaretheoremstyle[
headfont=\bfseries\color{lemmaTitle!80!black},
bodyfont=\itshape\color{lemmaBody},
mdframed={
linewidth=1pt,
rightline=false, topline=false, bottomline=false,
linecolor=lemmaTitle, backgroundcolor=pageColor,
}
]{lemmabox}
宣言:
\declaretheorem[
style=lemmabox,
name=Lemma,
parent=section,
sibling=definition,
]{lemma}
为什么会发生这种情况?我该如何解决?万一它很重要,因为它似乎对与此类似的问题(但对于其他软件包)很重要,我正在将其用作pdflatex
发行版(特别是不是luatex
或xelatex
),并且xcolor
对于处理颜色也很重要。我尝试将环境或整个页面包装在tcolorbox
允许颜色堆叠的环境中,但这会产生一大堆其他问题(并且不能真正解决问题)。
演示问题的最小示例:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[framemethod=TikZ]{mdframed}
\mdfsetup{skipabove=1em,skipbelow=0em}
\declaretheoremstyle[
headfont=\bfseries\color{blue},
bodyfont=\itshape\color{red},
mdframed={linewidth=1pt, rightline=false, topline=false, bottomline=false, linecolor=green}
]{lemmabox}
\declaretheorem[style=lemmabox, name=Lemma]{lemma}
\begin{document}
\vspace*{40em}
\begin{lemma}[Test]
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
\end{lemma}
\end{document}
答案1
下面是使用 tcolorbox\tcolorboxenvironment
命令的选项use color stack
:
\documentclass[12pt]{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage[skins,breakable]{tcolorbox}
\declaretheoremstyle[
headfont=\bfseries\color{blue},
bodyfont=\itshape\color{red}
]{lemmabox}
\declaretheorem[style=lemmabox, name=Lemma]{lemma}
\tcolorboxenvironment{lemma}{
blanker,
breakable,
left=5mm,
before skip=10pt,
after skip=10pt,
borderline west={1pt}{0pt}{green},
pad before break=2pt,
pad after break=2pt,
use color stack,
}
\begin{document}
\vspace*{42em}
\begin{lemma}[Test]
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
\end{lemma}
\end{document}
这些选项大部分是从tcolorbox 手册。