一个易碎的盒子放在另一个易碎的盒子里,就不会再易碎了

一个易碎的盒子放在另一个易碎的盒子里,就不会再易碎了

我使用下面的代码来制作一些精美的盒子。

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


\newcommand{\mytitlegen}{                  
    \node[fill=white,%rounded corners,
    draw=white,text=black,line width=3pt,inner sep=4pt,anchor=west,xshift=60pt]
    at (frame.north west){\bfseries In title};}

\newtcolorbox{InsideBox}{                       
    drop shadow=black!50!white,enhanced,overlay unbroken and first={\mytitlegen},colframe=black,colback=white,coltitle=black,boxrule=1pt,arc=3mm,%
    breakable,top=5pt,before=\vskip18pt,width=0.95\linewidth}

\makeatletter
\newtcolorbox{OutBox}[1][]{%
    enhanced, 
    breakable,
    before upper={\parindent15pt},
    colback=white,
    colframe=gray,
    attach boxed title to top right={yshift=-2pt}, title={Out title},
    boxed title size=standard,
    boxrule=0pt,
    boxed title style={%
        sharp corners, 
        rounded corners=northeast, 
        colback=tcbcolframe, 
        boxrule=0pt},
    sharp corners=north,
    overlay unbroken={%
        \path[fill=tcbcolback] 
        ([xshift=2pt]title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west) |- 
        ([xshift=2pt]title.south west)--cycle;
        \path[fill=tcbcolframe] (title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west)
        [rounded corners=\kvtcb@arc] |- 
        (title.north-|frame.north) 
        [sharp corners] -| (title.south west);
        \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcolframe] 
        (title.north east) rectangle 
        (frame.south west);
    }, 
    overlay first={%
        \path[fill=tcbcolback] 
        ([xshift=2pt]title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west) |- 
        ([xshift=2pt]title.south west)--cycle;
        \path[fill=tcbcolframe] (title.south west) 
        to[out=180, in=0] ([xshift=-1.5cm]title.west)--
        (title.west-|frame.west)
        [rounded corners=\kvtcb@arc] |- 
        (title.north-|frame.north) 
        [sharp corners] -| (title.south west);
        \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcolframe] 
        (frame.south west) |- (title.north) -| 
        (frame.south east);
    }, 
    overlay middle={%
        \draw[line width=.5mm, tcbcolframe] 
        (frame.north west)--(frame.south west) 
        (frame.north east)--(frame.south east);
    }, 
    overlay last={%
        \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
        tcbcolframe] 
        (frame.north west) |- (frame.south) -|
        (frame.north east);
    }, 
    #1
}
\makeatother

\begin{document}

    \begin{InsideBox}
\lipsum[1-6]
    \end{InsideBox}

\begin{OutBox}
\lipsum[1-6]
\end{OutBox}

     \end{document}

如你所见,一切正常。

在此处输入图片描述

但我想说的是InsideBox但我OutBox所以我尝试写

 \begin{OutBox}
        \lipsum[1]
            \begin{InsideBox}
            \lipsum[1-6]
        \end{InsideBox}
    \end{OutBox}

\lipsum

然后,如你所见,一切都乱了!InsideBox不再可破坏,并且有一些文本进入了OutBox

在此处输入图片描述

发生了什么事?提前致谢!

相关内容