5

I'm using tcolorbox theorems as following:

\usepackage{tcolorbox}
\tcbuselibrary{theorems}
\newtcbtheorem[number within=section]{example}{Example}%
{colback=green!5,colframe=green!35!black,fonttitle=\bfseries}{x}

This works great and looks really good. But if I've got text in my example that is bigger then the actual page it keeps on printing until the edge of the page and then disappears. It would be inconvenient to split the example into 2 examples. Is there any way I can get LaTeX to automatically split these boxes?

8

Add the breakable key to allow page breaks; this requires adding the breakable library, or you can load tcolorbox with the many option to load breakable and theorems libraries and some other ones:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{lipsum}

\newtcbtheorem[number within=section]{example}{Example}{
  breakable,
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries}{x}

\begin{document}

\begin{example}{Some example}{test}
\lipsum[1-8]
\end{example}

\end{document}

enter image description here

If you want to remove the border rule at the bottom on page breaks, add enhanced:

\newtcbtheorem[number within=section]{example}{Example}{
  breakable,
  enhanced,
  colback=green!5,
  colframe=green!35!black,
  fonttitle=\bfseries}{x}
  • Thank you, I guess I should read the manual more carefully :) Is there any way to remove the bottom border before a page break? So the reader knows that there is more on the next page. – Johann Bauer Mar 3 '15 at 16:46
  • 2
    @jreuab You're welcome. Please see my updated answer. – Gonzalo Medina Mar 3 '15 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.