¿Por qué la superposición funciona solo en el primer tcolorbox?

¿Por qué la superposición funciona solo en el primer tcolorbox?

Estoy intentando crear uno personalizado tcolorboxcon algún código TikZ en la overlayopción.

Pero sólo funciona la primera vez que uso mi nueva caja. ¿Qué estoy haciendo mal?

\documentclass{book}
\usepackage{tikzlings}
\usepackage{mwe}

\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[1][]{%
    enhanced,
    before skip=30ex,
    after skip=10ex,
    colback=yellow, 
    frame hidden,% from https://tex.stackexchange.com/a/247509/101651
    % from https://tex.stackexchange.com/a/431760/101651:
    overlay={%
        \begin{scope}
            \clip (frame.north west) -- (frame.north east) -- ++(0,+10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \marmot[xshift=.5\linewidth]
        \end{scope}
        \begin{scope}
            \clip (frame.south west) -- (frame.south east) -- ++(0,-10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \marmot[xshift=.5\linewidth, yshift=-\tcbtextheight-2ex]
        \end{scope}
    }
}
\begin{document}
    \begin{mybox}
         We love Ti\emph{k}Zlings!
    \end{mybox}
    \begin{mybox}
        \blindtext
    \end{mybox}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta1

¡Oh, no! ¡No hay marmota en la segunda caja! ¡Esto hay que rectificarlo! (Como lo mencionó @samcarter, la marmota fue cortada. Pero uno puede devolverla a la región visible).

\documentclass{book}
\usepackage{tikzlings}
\usepackage{mwe}

\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[1][]{%
    enhanced,
    before skip=30ex,
    after skip=10ex,
    colback=yellow, 
    frame hidden,% from https://tex.stackexchange.com/a/247509/101651
    % from https://tex.stackexchange.com/a/431760/101651:
    overlay={%
        \begin{scope}
            \clip (frame.north west) -- (frame.north east) -- ++(0,+10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \marmot[shift={([yshift=-7ex]frame.north)},whiskers,teeth]
        \end{scope}
        \begin{scope}
            \clip (frame.south west) -- (frame.south east) -- ++(0,-10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \marmot[shift={([yshift=-4ex]frame.south)},whiskers,teeth]
        \end{scope}
    }
}
\begin{document}
    \begin{mybox}
         We love Ti\emph{k}Zlings!
    \end{mybox}
    \begin{mybox}
        \blindtext
    \end{mybox}
\end{document}

ingrese la descripción de la imagen aquí

Algunos otros tikzlings se unieron a la fiesta.

\documentclass{book}
\usepackage{tikzlings}
\usepackage{mwe}

\usepackage[most]{tcolorbox}

\newtcolorbox{mybox}[1][]{%
    enhanced,
    before skip=30ex,
    after skip=10ex,
    colback=yellow, 
    frame hidden,% from https://tex.stackexchange.com/a/247509/101651
    % from https://tex.stackexchange.com/a/431760/101651:
    overlay={%
        \begin{scope}
            \clip (frame.north west) -- (frame.north east) -- ++(0,+10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \marmot[shift={([yshift=-7ex]frame.north)},whiskers,teeth]
            \koala[shift={([yshift=-7ex,xshift=-5em]frame.north)}]
            \mouse[shift={([yshift=-7ex,xshift=5em]frame.north)}]
        \end{scope}
        \begin{scope}
            \clip (frame.south west) -- (frame.south east) -- ++(0,-10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \marmot[shift={([yshift=-4ex]frame.south)},whiskers,teeth]
            \koala[shift={([yshift=-4ex,xshift=-5em]frame.south)}]
            \mouse[shift={([yshift=-4ex,xshift=5em]frame.south)}]
        \end{scope}
    }
}
\begin{document}
    \begin{mybox}
         We love Ti\emph{k}Zlings!
    \end{mybox}
    \begin{mybox}
        \blindtext
    \end{mybox}
\end{document}

ingrese la descripción de la imagen aquí

Y cheeseboxtiende a atraer ratones (conaporte importante de @samcarter en el chat).

\documentclass{book}
\usepackage{tikzlings}
\usepackage{mwe}

\usepackage[most]{tcolorbox}

\newtcolorbox{mousebox}[1][]{%
    enhanced,
    before skip=30ex,
    after skip=10ex,
    underlay={%
        \begin{tcbclipinterior}
            \fill [yellow]
              (interior.south west) rectangle (interior.north east);
              \path let \p1=($(interior.north east)-(interior.south west)$)
              in [/utils/exec={\pgfmathtruncatemacro{\NX}{1+\x1*1pt/3cm}
              \pgfmathtruncatemacro{\NY}{1+\y1*1pt/2cm}\xdef\NX{\NX}
              \xdef\NY{\NY}}];
              \foreach \X in {1,...,\NX}
              {\foreach \Y in {1,...,\NY}
              { \foreach \x/\y/\r in {0.4/0.6/0.3, 
               0.5/1.3/0.2,%
               1.5/0.5/0.4,%
               1.5/0.5/0.4,% 
               2.1/1.5/0.3,%
               2.5/0.8/0.2,% 
               3.3/1.1/0.3}
               {\shade[ball color=yellow!80!orange,opacity=0.2] 
               ({\x+(\X-1)*3},{\y+(\Y-1)*2}) circle (\r);}
               }}
        \end{tcbclipinterior},
        },
    %colback=yellow, 
    frame hidden,% from https://tex.stackexchange.com/a/247509/101651
    % from https://tex.stackexchange.com/a/431760/101651:
    overlay={%
        \begin{scope}
            \foreach \Y in {-5,0,5}
            {\begin{scope}[shift={([yshift=-9ex,xshift=\Y em]frame.north)}]
             \path[fill=gray!50]
             (0.5, 1.8) .. controls (0.5, 1.58) and (0.2, 1.25) .. (0, 1.16) .. controls (-0.2, 1.25) and (-0.5, 1.58) .. (-0.5, 1.8) .. controls (-0.34, 2.3) and (0.34, 2.3) .. (0.5, 1.8) -- cycle;
             \path[fill=gray!50!black] (0, 1.248) circle (0.09);
             \foreach \X in {10,20,33}{%
                \fill[gray!50!black] (0,1.2) + (\X:0.08) to[out=\X,in={180-\X}] ++({\X-20}:0.3) --++(0,0.01) to[out={180-\X},in=\X] cycle (0,1.2) + ({180-\X}:0.08) to[out={180-\X},in=\X] ++({200-\X}:0.3) --++(0,0.01) to[out=\X,in={180-\X}] cycle;
              }
             \end{scope} 
             }
            \clip (frame.north west) -- (frame.north east) -- ++(0,+10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \foreach \Y in {-5,0,5}
            {\mouse[shift={([yshift=-9ex,xshift=\Y em]frame.north)}]}
        \end{scope}
        \begin{scope}
            \clip (frame.south west) -- (frame.south east) -- ++(0,-10ex) -- 
            ++(-\linewidth,0) -- cycle;
            \foreach \X in {-5,0,5}
            {
            \mouse[shift={([yshift=-4ex,xshift=\X em]frame.south)}]}
        \end{scope}
    }
}
\begin{document}
    \begin{mousebox}
         We love cheese!
    \end{mousebox}
    \begin{mousebox}
        \blindtext
    \end{mousebox}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada