8

I'd like to apply (drop lifted) shadow only to the last part of a breakable tcolorbox but I couldn't find any hint for this in the documentation. The following MWE is a non working attempt.

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{mwe}
\tcbuselibrary{breakable,skins}
\begin{document}
\begin{tcolorbox}[breakable,drop lifted shadow,skin=enhancedlast]
  \lipsum[1-5]
\end{tcolorbox}
\end{document}

Hence my question: is it possible to apply shadow only to the last part of a breakable tcolorbox?

2 Answers 2

8

Version 1 (extras):

The maybe shortest solution is to take advantage of the new extras options from tcolorbox 3.70 (2015/07/16) or newer. These allow to place options for different parts of a break sequence. Here, we need extras unbroken or last:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{mwe}
\tcbuselibrary{breakable,skins}
\begin{document}
\begin{tcolorbox}[breakable,
    extras unbroken and last={drop lifted shadow},
    skin=enhancedlast ]
  \lipsum[1-5]
\end{tcolorbox}
\end{document}

Version 2 (skins):

Here's another alternative. In any case, a change of the skin is the way to a solution. If the main skin is enhancedlast, the break sequence will be enhancedmiddle (first), enhancedmiddle (middle), enhancedlast (last).

Using the subskin feature, I take this standard sequence and add the appropriate shadow options. This gives:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{mwe}
\tcbuselibrary{breakable,skins}
\begin{document}
\begin{tcolorbox}[breakable,drop lifted shadow,
  skin=enhancedlast,
  skin first is subskin of={enhancedmiddle}{no shadow},
  skin middle is subskin of={enhancedmiddle}{no shadow},
  skin last is subskin of={enhancedlast}{drop lifted shadow} ]
  \lipsum[1-5]
\end{tcolorbox}
\end{document}

enter image description here

1
  • 1
    Argg. I got the break sequence wrong while I tried the exactly same strategy. I should learn these breaks +1 :)
    – user11232
    Jan 18, 2015 at 0:07
5

Yes, it's possible. I defined a new style and a new skin (similar to enhancedmiddle) allowing to do this (perhaps there's a simpler solution):

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{tcolorbox}
\usepackage{lipsum}
\tcbuselibrary{breakable,skins}

\makeatletter
\tcbset{
  mybase@middle/.style={%
    clear@spec,graphical environment=tikzpicture@tcb@hooked,geometry nodes,%
    set@outerboundary=\tcb@boundaryframe@pathmiddle,%
    shape@of@skin=middle,%
    set@extensions@preframe={},%
    set@extensions@postframe={\tcb@draw@border@middle\tcb@apply@underlay\tcb@apply@overlay},%
    set@extensions@final={\tcb@apply@finish}%
  }
}
\tcb@new@skin{myenhancedmiddle}{
  mybase@middle,%
  frame engine=pathmiddle,
  interior titled engine=pathmiddle,
  interior engine=pathmiddle,
  segmentation engine=path,
  title engine=pathmiddle,%
  skin first=enhancedmiddle,
  skin middle=enhancedmiddle,
  skin last=enhancedmiddle
}
\makeatother

\begin{document}

\begin{tcolorbox}[
  breakable,
  skin=myenhancedmiddle,
  skin first=myenhancedmiddle,
  skin middle=myenhancedmiddle,
  drop lifted shadow
]
\lipsum[1-4]
\end{tcolorbox}

\end{document}

The output showing that only the LAST part of the broken box receives the shadow:

enter image description here

You must log in to answer this question.

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