2

I have some text with tcolorboxes interspersed with normal paragraphs. Everything looks lovely so far, even when the tcolorboxes have to break across pages (using the breakable option).

However, I now need to put a shaded background behind some of the text. The obvious solution would be another tcolorbox…but a tcolorbox inside a tcolorbox can never be breakable (as the MWE shows; this is in the documentation also).

What other options do I have to put a shaded box behind a few pages' worth of text? I don't need any of the fancy features of tcolorbox (like the rounded corners or title bar or adjusted margins), I just need a nice gray color behind the text. I've tried mdframed also, but mixing mdframed and tcolorbox seems to be discouraged, and it sometimes put breaks in completely wrong places.

MWE:

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

\begin{document}

\begin{tcolorbox}[breakable]
\lipsum[1-2]
    \begin{tcolorbox}[breakable]
    \lipsum[3-10]
    \end{tcolorbox}
\end{tcolorbox}

\end{document}
Draconis
  • 900
  • You can use an overlaying tikzpicture. Have a look at the questions on this site with "tikz" and "background". – TeXnician Dec 02 '18 at 19:51
  • It's not possible to break nested tcolorboxes, but you could try with something similar to this. There you have three kind of boxes: top, middle and bottom, all breakable which try to emulate a two level nested breakable tcolorbox. – Ignasi Dec 03 '18 at 10:00

0 Answers0