thmtools 与 mdframed 搭配使用时,会在分页符处删除字体颜色

thmtools 与 mdframed 搭配使用时,会在分页符处删除字体颜色

现在,我使用thmtoolswithmdframed创建带有边线的定理环境。困难在于我还想能够更改这些定理环境中文本的颜色。问题是使用预期方法(参数\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发行版(特别是不是luatexxelatex),并且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 手册

相关内容