1

Since breakable boxes in breakables boxes are not possible, as discussed in Breakable box in breakable box with tcolorbox and in the manual of tcolorbox.

So I thought of an alternative: is it possible to put breakable boxes behind each other (overlap)? The box in the background is a little bit larger than the box in the foreground, so it seems to be 'a box in a box', but in reality it are just breakable boxes outside each other. One would expect they break normally?

For example, from the the manual of tcolorbox. How can I simulate the 'the box in a box' by overlapping, so that one would expect they break normally? enter image description here

  • I think you can always play with overlays and borders to simulate a box inside the other. But with a more accurate description of this problem and even some graphic scheme, it will be easier to understand and answer the question. – Ignasi Mar 16 '18 at 8:03
  • @Ignasi Thanks for your answer! I added an example of the manual of tcolorbox – Faceb Faceb Mar 16 '18 at 16:32
5

This is just an idea.

As nested boxes are unbreakable a possible solution when we have only two nested boxes consist in defining the inner box as breakable and draw the outer one with some overlay options.

To simulate the inner box, we have to adjust margins with enlarge ... option and also define the corresponding width. Title, colframe and colback for outer box are fixed in overlay commands. Probably outer box geometry is not correct but I left to you to use better adjusted dimensions.

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

\newtcolorbox{myfakebreakablebox}[2][]{
    title=#2,
    enhanced, breakable, 
    enlarge top initially by=1cm,
    enlarge bottom finally by=5mm,
    enlarge left by=5mm,
    enlarge right by=5mm,
    width=\linewidth-10mm,
    overlay first={
        \draw[green!70!black, line width=.5mm, rounded corners]
            ([xshift=-5mm]frame.south west)|-([yshift=1cm]frame.north)-|
            ([xshift=5mm]frame.south east);
        \node[fill=green!70!black, minimum height=5mm, 
            minimum width=\linewidth, anchor=north] at ([yshift=1cm]frame.north) 
            (outertitle) {};
        \node[text=white, anchor=west] at ([xshift=3mm]outertitle.west) {Outer title};
        },
    overlay middle={
        \draw[green!70!black, line width=.5mm, rounded corners]
             ([xshift=-5mm]frame.north west)--([xshift=-5mm]frame.north west);
        \draw[green!70!black, line width=.5mm, rounded corners]
             ([xshift=-5mm]frame.north east)--([xshift=-5mm]frame.north east);
    },
    overlay last={
        \draw[green!70!black, line width=.5mm, rounded corners]
             ([xshift=-5mm]frame.north west)|-([yshift=-5mm]frame.south)
             -|([xshift=5mm]frame.north east);
    }
}

\begin{document}
\lipsum[1-3]
\begin{myfakebreakablebox}{this is the title}
\lipsum[1-3]
\end{myfakebreakablebox}
\lipsum[1]
\end{document}

enter image description here

| improve this answer | |
  • may I ask, where have you defined the inner box? Where have you defined it to be black? – Faceb Faceb Mar 23 '18 at 16:58
  • @FacebFaceb Not default but initial colors: colframe= black!75!white, colback=black!5!white. Page 27 in tcolorbox documentation. – Ignasi Mar 23 '18 at 18:55
  • but where is 'colframe = black!75!white, colback = black!5!white' in your code? – Faceb Faceb Mar 23 '18 at 19:20
  • @FacebFaceb . If you dont fix them, these are the used values. – Ignasi Mar 23 '18 at 23:50
  • is it possible that you comment every line/command in your code, so I can know how this has been achieved? Thanks! :) – Faceb Faceb Mar 24 '18 at 6:59

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.