2

I am using amsmath, thmtools and the following definition to get nice Theorem statements inside a light blue box:

\declaretheoremstyle[
  shaded={bgcolor=blue!10},
  numberwithin=section
]{mythmstyle}
\declaretheorem[style=mythmstyle]{theorem}

My problem is that these boxes containing theorem statements do not split between pages. Since I tend to use long statements, this produces big unbreakable blocks and the formatting of pages is terrible.

To clarify: I want to modify my settings so that page formatting can split Theorems between pages, which it seems unable to do at the moment. How can I do?

If I remove the `shaded' option, breaking returns to normal, so that should be the culprit

EDIT: a solution is to use the framed package. Using amsthm, I define a pre-theorem environment, to get counters right

\newtheorem{pretheorem}{Theorem}[section]

and then the true theorem environment is defined by inserting a frame as follows:

\newenvironment{theorem}
   {\colorlet{shadecolor}{blue!15}
   \begin{snugshade}\begin{pretheorem}}
   {\end{pretheorem}\end{snugshade}}

Not too elegant but it seems to work.

2
  • 1
    You woud have no problem with the ntheorem packaged which enables you to define framed, shaded and boxed theorems that can break across pages. This package requires the framed package and cooperates with thmtools. Have a look at § 237, "Framed and Boxed Theorems", pp. 9-10 in the documentation.
    – Bernard
    Aug 24, 2022 at 14:17
  • Thank you. Unfortunately, ntheorem conflicts with amsbook which I am using Aug 24, 2022 at 23:12

1 Answer 1

2

Can you switch to tcolorbox instead of thmtools?

\documentclass{article}

\usepackage{blindtext}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,theorems}

\newtcbtheorem[number within=section]{mytheorem}{Theorem}{breakable,colback=teal!20,colframe=blue,fonttitle=\bfseries}{thm}

\begin{document}
    \begin{mytheorem}{A theorem}{label}
        \blindtext[5]
    \end{mytheorem}
    Refer it like this: Theorem \ref{thm:label}.
\end{document}

Page 1:

enter image description here

Page 2:

enter image description here

4
  • Interesting. But this would force me to change my labeling system, for which I have macros in place etc. I think for me the minimal solution with the framed package is better Aug 26, 2022 at 9:05
  • 1
    Yes, I had expected that suddenly switching packages would cause a lot of overhead. Did you have a look at tex.stackexchange.com/questions/34405/… ?
    – Zxcvasdf
    Aug 26, 2022 at 9:08
  • No, I looked into older posts but this one did not come up. The solution proposed there seems fine. As for complexity it looks the same as the above hack with framed. Do you see any advantages? Aug 26, 2022 at 22:01
  • 1
    I agree with you. The first part of the answer looks the same. But the second part explains how to incorporate it within thmtools's commands. I thought it might be what you were looking for. You are the best judge anyway :)
    – Zxcvasdf
    Aug 28, 2022 at 11:59

You must log in to answer this question.

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