1

Right now, I use thmtools with mdframed to create theorem environments with lines down the side. The difficulty is that I also want to be able to change the color of the text in these theorem environments. The issue is that defining this color using the expected method (a \color{} call in the bodyfont parameter) has a bug: it cuts off at page break.

enter image description here

Style:

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

Declaration:

\declaretheorem[
    style=lemmabox,
    name=Lemma,
    parent=section,
    sibling=definition,
]{lemma}

Why is this happening, and how can I fix it? In case it matters, as it seems to matter for questions similar to this one (but for other packages) I'm using pdflatex as the distribution (in particular, not luatex or xelatex), and xcolor for handling color. I've tried wrapping the environment or the entire page in a tcolorbox that allows for color stacking, but this creates a whole host of other issues (and doesn't really fix the problem).

Minimal example demonstrating issue:

\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}
3
  • Please add a complete example (from \documentclass to \end{document}) that displays the issue
    – mbert
    May 28, 2023 at 3:33
  • @mbert, thanks for the note. Added a minimal (nonworking) example. May 28, 2023 at 4:30
  • Possible duplicate of tex.stackexchange.com/questions/268917/…
    – mbert
    May 28, 2023 at 4:42

1 Answer 1

1

Here's an option using tcolorbox's \tcolorboxenvironment command with the use color stack option:

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

enter image description here

The options were mostly copied from section 18.4 of the tcolorbox manual.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .