0

Using the same code as in How to customize title of 'the breakable boxes inside breakable boxes'? with many thanks to @Ignasi, I encountered the following problems:

An example:

% !TeX program = xelatex

\documentclass[fromlogo = true]{article}
\usepackage{varwidth,cancel}

\usepackage{eso-pic,mathtools}
\usepackage{tikz}
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse}
\tikzset{coltria/.style = {fill=bllue}}
\tikzset{cccoltria/.style= {fill=bllack}}
\tikzset{cccccoltria/.style = {fill=red}}
\usepackage{refcount}
\usetikzlibrary{backgrounds,calc}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\usepackage{fontspec}
\usepackage[first=-90, last = 90]{lcg}
\newcommand{\random}{0.2*rand}
\newcommand{\rulewidth}{5 mm}

\definecolor{grey}{RGB}{220,220,220}

\usepackage{varwidth}

\allowdisplaybreaks

\usepackage{polyglossia}
\usepackage{amsmath}
\usetikzlibrary{shapes.callouts,shapes.arrows,matrix,shapes.misc,shadows.blur,shapes,arrows, patterns, hobby,shapes.multipart}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}


\definecolor{bllue}{RGB}{0,0,255}
\definecolor{bllack}{RGB}{0,255,0}


\newcommand{\bllackpicture}{\textcolor{black}{Box}}

\newcommand{\redpicture}{
    \textcolor{red}{Box}}

\newcommand{\blluepicture}{
    \textcolor{bllue}{Box}}



\newcommand{\Rn}{purple}

\tcbset{setskinf/.style = {skin first is subskin of={emptyfirst}{
            oversize, enhanced,
            frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
                \path[#1] ([xshift = 2.5mm, yshift = 1mm]frame.south west) -- +(120:2mm) -- +(60:2mm)-- cycle;},
            interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;}
            ,}}}
\tcbset{setskinm/.style = {
        skin middle is subskin of={emptymiddle}{
            oversize, enhanced,
            frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
                \path[#1] ([xshift = 2.5mm, yshift = -1mm]frame.north west) -- +(240:2mm) -- +(300:2mm)-- cycle;
                \path[#1] ([xshift = 2.5mm, yshift = 1mm]frame.south west) -- +(120:2mm) -- +(60:2mm)-- cycle;},
            interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;}
            ,}}}
\tcbset{setskinl/.style = {
        skin last is subskin of={emptylast}{
            oversize, enhanced,
            frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
                \path[#1] ([xshift = 2.5mm, yshift = -1mm]frame.north west) -- +(240:2mm) -- +(300:2mm)-- cycle;},
            interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;}
            ,}}}

\tcbset{boxedtitle/.style = {attach boxed title to top left = {xshift = 1cm, yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
        boxed title style={frame code = {
                \path[fill=tcbcol@back!30!black]
                ([yshift = -1mm,xshift = -1mm] frame.north west)
                arc[start angle=0,end angle=180,radius=1mm]
                ([yshift = -1mm,xshift = 1mm] frame.north east)
                arc[start angle = 180, end angle = 0, radius = 1mm];
                \path[left color = tcbcol@back!60!black, right color = tcbcol@back!60!black, middle color = tcbcol@back!80!black]
                ([xshift=-2mm]frame.north west)--([xshift=2mm]frame.north east) [rounded corners=1mm]--([xshift=1mm,yshift=-1mm]frame.north east) --(frame.south east)--(frame.south west)
                --([xshift=-1mm,yshift=-1mm]frame.north west)
                [sharp corners]-- cycle;
            },interior engine=empty,
        },
        fonttitle=\bfseries}}

    \tcbset{normal/.style n args = {1}{enlarge top initially by = 1cm,enlarge bottom finally by = 7mm,enlarge left by = 5mm,
            enlarge right by = 5mm,
            width = \linewidth+2cm,
                overlay unbroken = {\draw[\Rn!70!black, line width = .8mm, rounded corners]
                    ([xshift = -5mm, yshift = -5mm]frame.south west)|-([yshift = 9mm]frame.north)-|
                    ([xshift = 5mm, yshift = -5mm]frame.south east) -- cycle;
                    \coordinate (outernw) at ([shift = {(-5mm,1cm)}]frame.north west);
                    \node[fill=\Rn!70!black, minimum height = 5mm,
                    anchor = north west, text = white, rounded corners] at ([xshift = 1cm]outernw) (outertitle) {Title #1};
                    \path[fill = \Rn!30!black]
                    ([yshift = -1mm, xshift = -1mm]outertitle.north west)
                    arc[start angle = 0, end angle = 180, radius = 1mm]
                    ([yshift = -1mm, xshift = 1mm]outertitle.north east)
                    arc[start angle = 180, end angle = 0, radius = 1mm];
                    \path[left color = \Rn!60!black, right color = \Rn!60!black, middle color = \Rn!80!black]
                    ([xshift = -2mm]outertitle.north west) -- ([xshift = 2mm]outertitle.north east)[rounded corners = 1mm]
                    -- ([xshift = 1mm, yshift = -1mm]outertitle.north east) -- (outertitle.south east) -- (outertitle.south west)
                    -- ([xshift = -1mm, yshift = -1mm]outertitle.north west)
                    [sharp corners] -- cycle;
                    \node[text = white] at (outertitle) {Title #1};
                },
            overlay first = {\draw[\Rn!70!black, line width = .8mm, rounded corners]
                ([xshift = -5mm]frame.south west)|-([yshift = 9mm]frame.north)-|
                ([xshift = 5mm]frame.south east);
                \coordinate (outernw) at ([shift = {(-5mm,1cm)}]frame.north west);  
                \node[fill=\Rn!70!black, minimum height = 5mm,
                anchor = north west, text = white, rounded corners] at ([xshift = 1cm]outernw) (outertitle) {Question #1};
                \path[fill = \Rn!30!black]
                ([yshift = -1mm, xshift = -1mm]outertitle.north west)
                arc[start angle = 0, end angle = 180, radius = 1mm]
                ([yshift = -1mm, xshift = 1mm]outertitle.north east)
                arc[start angle = 180, end angle = 0, radius = 1mm];
                \path[left color = \Rn!60!black, right color = \Rn!60!black, middle color = \Rn!80!black]
                ([xshift = -2mm]outertitle.north west) -- ([xshift = 2mm]outertitle.north east)[rounded corners = 1mm]
                -- ([xshift = 1mm, yshift = -1mm]outertitle.north east) -- (outertitle.south east) -- (outertitle.south west)
                -- ([xshift = -1mm, yshift = -1mm]outertitle.north west)
                [sharp corners] -- cycle;
                \node[text = white] at (outertitle) {Question #1};
},
            overlay middle = {
                \draw[\Rn!70!black, line width = .8mm]
                ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
                ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
},
overlay last = {\draw[\Rn!70!black, line width = .8mm, rounded corners]
    ([xshift = -5mm]frame.north west)|-([yshift = -5mm]frame.south)-|
    ([xshift = 5mm]frame.north east);
}
}}

\tcbset{top/.style n args = {1}{enlarge top initially by = 1cm, enlarge bottom finally by = 1mm,
        enlarge left by = 5mm,
        enlarge right by = 5mm,
        width = \linewidth+2cm,
        overlay unbroken and first = {
            \draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm, yshift = -2mm]frame.south west)|-([yshift = 9mm]frame.north)-|
            ([xshift = 5mm, yshift = -2mm]frame.south east);
            \coordinate (outernw) at ([shift = {(-5mm,1cm)}]frame.north west);  
            \node[fill=\Rn!70!black, minimum height = 5mm,
            anchor = north west, text = white, rounded corners] at ([xshift = 1cm]outernw) (outertitle) {Title #1};
        \path[fill = \Rn!30!black]
        ([yshift = -1mm, xshift = -1mm]outertitle.north west)
        arc[start angle = 0, end angle = 180, radius = 1mm]
        ([yshift = -1mm, xshift = 1mm]outertitle.north east)
        arc[start angle = 180, end angle = 0, radius = 1mm];
        \path[left color = \Rn!60!black, right color = \Rn!60!black, middle color = \Rn!80!black]
        ([xshift = -2mm]outertitle.north west) -- ([xshift = 2mm]outertitle.north east)[rounded corners = 1mm]
        -- ([xshift = 1mm, yshift = -1mm]outertitle.north east) -- (outertitle.south east) -- (outertitle.south west)
        -- ([xshift = -1mm, yshift = -1mm]outertitle.north west)
        [sharp corners] -- cycle;
        \node[text = white] at (outertitle) {Title #1};
    },
        overlay middle and last = {
            \draw[\Rn!70!black, line width = .8mm]
            ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
            ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
}}}

\tcbset{middle/.style n args = {1}{enlarge top initially by = 1mm, enlarge bottom finally by = 1mm,
enlarge left by = 5mm,
enlarge right by = 5mm,
width = \linewidth+2cm,
overlay unbroken = {
\draw[\Rn!70!black,line width = .8mm]
    ([shift = {(-5mm,3mm)}]frame.north west)--([shift = {(-5mm,-3mm)}]frame.south west)
    ([shift = {(5mm,3mm)}]frame.north east)--([shift = {(5mm,-3mm)}]frame.south east);
},
overlay first = {
    \draw[\Rn!70!black,line width = .8mm]
    ([shift = {(-5mm,5mm)}]frame.north west)--([xshift = -5mm]frame.south west)
    ([shift = {(5mm,5mm)}]frame.north east)--([xshift = 5mm]frame.south east);
},
overlay middle = {
    \draw[\Rn!70!black,line width = .8mm]
    ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
    ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
},
overlay last = {
    \draw[\Rn!70!black,line width = .8mm]
    ([xshift = -5mm]frame.north west)--([shift = {(-5mm,-5mm)}]frame.south west)
    ([xshift = 5mm]frame.north east)--([shift = {(5mm,-5mm)}]frame.south east);
},
}}

\tcbset{bottom/.style = {enlarge bottom finally by = 7mm, enlarge top initially by = 1mm,
        enlarge left by = 5mm,
        enlarge right by = 5mm,
        width = \linewidth+2cm,
        overlay unbroken and last = {
            \draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm, yshift = 2mm]frame.north west)|-([yshift = -5mm]frame.south)-|
            ([xshift = 5mm, yshift = 2mm]frame.north east);
        },
        overlay first and middle = {
            \draw[\Rn!70!black, line width = .8mm]
            ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
            ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
}}}

\newtcolorbox{generic}[5][]{empty,leftrule=\rulewidth,oversize, enhanced,
    frame style = {left color = #2!20, right color = white},interior style = {left color = #2!5, right color = white}, left = 0pt, right = 0pt, %top = 4pt, bottom = 4pt, 
    before skip = 0pt, after skip = 0pt,% boxrule = 0.1pt, 
    title = #3, underlay={\begin{tcbclipinterior}
            \shade[inner color = #2!10, outer color = white] (interior.north west) circle (2cm);
            \draw[help lines, step = 5mm, #2!5,shift={(interior.north west)}] (interior.south west) grid (interior.north east);
        \end{tcbclipinterior}
    }, drop small lifted shadow,
    breakable,rotate = \random
    ,
    frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
    },
    interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;},
    % test
    setskinf = {#4},setskinm = {#4},setskinl = {#4},#5, #1}

\newcommand{\bllack}[3][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {normal = #2}
        #3
\end{generic}}

\newcommand{\tbllack}[3][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {top = #2}
        #3
\end{generic}}
\newcommand{\mbllack}[2][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {middle}
        #2
\end{generic}}
\newcommand{\bbllack}[2][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {bottom}
        #2
\end{generic}}

\newcommand{\red}[3][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {normal = #2}
        #3
\end{generic}}
\newcommand{\tred}[3][]{
\begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {top = #2}
#3
\end{generic}}
\newcommand{\mred}[2][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {middle}
        #2
\end{generic}}
\newcommand{\bred}[2][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {bottom}
        #2
\end{generic}}

\newcommand{\bllue}[3][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {normal = #2}
        #3
\end{generic}}
\newcommand{\tbllue}[3][]{
\begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {top = #2}
#3
\end{generic}}
\newcommand{\mbllue}[2][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {middle}
        #2
\end{generic}}
\newcommand{\bbllue}[2][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {bottom}
        #2
\end{generic}}

\newcommand{\tcblowerr}{\begin{tcblowerbox}%{middle}
        \tcblower
\end{tcblowerbox}}

\begin{document}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
%
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
%   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \red{{8}}{\lipsum[1-1]}
%   
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
%   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-2]}
    \red{{8}}{\lipsum[1-1]}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \red{{8}}{\lipsum[1-1]}
    %   
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-2]}
    \red{{8}}{\lipsum[1-1]}

\end{document}

enter image description here

  • The box in page 19 and 21 is broken, but why is not placed on page 18 an 20 resp?
  • Why are the boxes on page 22, 8 not exactly below each other?

So my main questions are

  • How can I force box on page 19 and 21 to be placed on page 18 and 20 resp?
  • How can I place boxes exactly below each other?
  • 3
    How can we know it without any other information? Do you know what's a Minimal Working example. We have no problem solving questions but don't leave all the job for us. Provide the failing code. Make questions that show that you are really trying to understand how the code works. "Do it for me" questions are not welcome. – Ignasi Apr 23 '18 at 07:37
  • @Ignasi, I am more than happy to post a MWE. But my code is quite long and extensive. Should I still post it? – Faceb Faceb Apr 23 '18 at 21:44
  • @Ignasi, I hope my question is clearer now – Faceb Faceb Apr 24 '18 at 05:14

2 Answers2

1

I don't want to dive into your code but something is wrong for sure. I've added show bounding box option to some of your boxes (\tred[show bounding box]{1}{\lipsum[1-1]}) and this is the result:

enter image description here

enter image description here

As you can see all boxes are perfectly aligned according the bounding box but in some of them the bounding box is not the external box. Now it's your turn to find the missalignment.

Some comments about the code.

It includes a lot of packages/libraries that the example doesn't use (mathtools, pgfplots, ...). It's better that you avoid them in your examples.

You declare styles with xxxxx/.style n args = {1}{. If style only uses one parameter you can declare it as non parametric style xxxxx/.style = { and still use #1 inside this style. .style declaration accepts one parameter by default.

Finally I think that rotate=\random in generic box will make a non perfect adjustement between different boxes.

Ignasi
  • 136,588
  • ok thanks for checking. I can see that the boxes are placed wrong only if they are broken, if they are unbroken they are ok – Faceb Faceb Apr 24 '18 at 17:12
  • do you have a hint perhaps? – Faceb Faceb Apr 24 '18 at 17:13
  • @FacebFaceb May be the broken boxes don't preserve the bounding box conditions. But It's just a suposition. – Ignasi Apr 24 '18 at 17:30
  • my solution is to shift all broken boxes to the right? – Faceb Faceb Apr 24 '18 at 17:34
  • do you know how my first question can be solved? – Faceb Faceb Apr 24 '18 at 17:37
  • @FacebFaceb About first question. Probably there is not enough space to make a 'nice' cut. About missalignment of broken boxes: My original code doesn't show this behaviour so it's not a problem with tcolorbox but with your final design. Try to find what's wrong with it. – Ignasi Apr 24 '18 at 17:46
  • that is strange, because the code for unbroken normal/.style is exactly the same as the overlay first except for cycle – Faceb Faceb Apr 24 '18 at 19:22
  • do you understand what is the cause of the problem I mentioned in my previous comment? – Faceb Faceb Apr 26 '18 at 14:12
  • after 1.5 months I still cannot find the error. I am beginner with LaTeX, so it is very hard for me to find the error as I am not an expert like you are ;) Maybe you can teach me how to find error as this, give tips so I can do it myself in the future? – Faceb Faceb Jun 19 '18 at 13:56
  • @FacebFaceb As I told you, your code is too complex to try to investigate. If you are able to simplify it and reduce the problem to on kind of box, may be we could help you better. How to find the errors? Making shorter tests in independent documents. Once a box works, try with another one and finally join them inside a complete document. Where to start? Look at page 2 in my results. The broken box shows a different bounding box from previous one. Try to see why. On page 3, last fragment is different from previous ones, why? If reduced problems doesn't help, make new questions. – Ignasi Jun 19 '18 at 14:59
  • I suspect it is the setskin that is the cause of the misalignment. Because when I removed it then the blocks were nicely stacked without offset – Faceb Faceb Jun 19 '18 at 15:31
0

Thanks to the advise of @Ignasi, the misalignment-problem (my second question) is solved. It is the oversize option in setskin that is the cause of misalignment.

However, my first question remains unsolved.

The code is now:

% !TeX program = xelatex

\documentclass[fromlogo = true]{article}
\usepackage{varwidth,cancel}

\usepackage{eso-pic,mathtools}
\usepackage{tikz}
\usepackage[many]{tcolorbox}
\tcbuselibrary{skins,breakable,xparse}
\tikzset{coltria/.style = {fill=bllue}}
\tikzset{cccoltria/.style= {fill=bllack}}
\tikzset{cccccoltria/.style = {fill=red}}
\usepackage{refcount}
\usetikzlibrary{backgrounds,calc}
\usepackage{tikzpagenodes}
\usepackage{lipsum}

\usepackage{fontspec}
\usepackage[first=-90, last = 90]{lcg}
\newcommand{\random}{0.2*rand}
\newcommand{\rulewidth}{5 mm}

\definecolor{grey}{RGB}{220,220,220}

\usepackage{varwidth}

\allowdisplaybreaks

\usepackage{polyglossia}
\usepackage{amsmath}
\usetikzlibrary{shapes.callouts,shapes.arrows,matrix,shapes.misc,shadows.blur,shapes,arrows, patterns, hobby,shapes.multipart}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}


\definecolor{bllue}{RGB}{0,0,255}
\definecolor{bllack}{RGB}{0,255,0}


\newcommand{\bllackpicture}{\textcolor{black}{Box}}

\newcommand{\redpicture}{
    \textcolor{red}{Box}}

\newcommand{\blluepicture}{
    \textcolor{bllue}{Box}}



\newcommand{\Rn}{purple}

\tcbset{setskinf/.style = {skin first is subskin of={emptyfirst}{
            enhanced,
            frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
                \path[#1] ([xshift = 2.5mm, yshift = 1mm]frame.south west) -- +(120:2mm) -- +(60:2mm)-- cycle;},
            interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;}
            ,}}}
\tcbset{setskinm/.style = {
        skin middle is subskin of={emptymiddle}{
            enhanced,
            frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
                \path[#1] ([xshift = 2.5mm, yshift = -1mm]frame.north west) -- +(240:2mm) -- +(300:2mm)-- cycle;
                \path[#1] ([xshift = 2.5mm, yshift = 1mm]frame.south west) -- +(120:2mm) -- +(60:2mm)-- cycle;},
            interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;}
            ,}}}
\tcbset{setskinl/.style = {
        skin last is subskin of={emptylast}{
            enhanced,
            frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
                \path[#1] ([xshift = 2.5mm, yshift = -1mm]frame.north west) -- +(240:2mm) -- +(300:2mm)-- cycle;},
            interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;}
            ,}}}

\tcbset{boxedtitle/.style = {attach boxed title to top left = {xshift = 1cm, yshift*=1mm-\tcboxedtitleheight}, varwidth boxed title*=-3cm,
        boxed title style={frame code = {
                \path[fill=tcbcol@back!30!black]
                ([yshift = -1mm,xshift = -1mm] frame.north west)
                arc[start angle=0,end angle=180,radius=1mm]
                ([yshift = -1mm,xshift = 1mm] frame.north east)
                arc[start angle = 180, end angle = 0, radius = 1mm];
                \path[left color = tcbcol@back!60!black, right color = tcbcol@back!60!black, middle color = tcbcol@back!80!black]
                ([xshift=-2mm]frame.north west)--([xshift=2mm]frame.north east) [rounded corners=1mm]--([xshift=1mm,yshift=-1mm]frame.north east) --(frame.south east)--(frame.south west)
                --([xshift=-1mm,yshift=-1mm]frame.north west)
                [sharp corners]-- cycle;
            },interior engine=empty,
        },
        fonttitle=\bfseries}}

\tcbset{normal/.style n args = {1}{enlarge top initially by = 1cm,enlarge bottom finally by = 7mm,enlarge left by = 5mm,
        enlarge right by = 5mm,
        width = \linewidth+2cm,
        overlay unbroken = {\draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm, yshift = -5mm]frame.south west)|-([yshift = 9mm]frame.north)-|
            ([xshift = 5mm, yshift = -5mm]frame.south east) -- cycle;
            \coordinate (outernw) at ([shift = {(-5mm,1cm)}]frame.north west);
            \node[fill=\Rn!70!black, minimum height = 5mm,
            anchor = north west, text = white, rounded corners] at ([xshift = 1cm]outernw) (outertitle) {Title #1};
            \path[fill = \Rn!30!black]
            ([yshift = -1mm, xshift = -1mm]outertitle.north west)
            arc[start angle = 0, end angle = 180, radius = 1mm]
            ([yshift = -1mm, xshift = 1mm]outertitle.north east)
            arc[start angle = 180, end angle = 0, radius = 1mm];
            \path[left color = \Rn!60!black, right color = \Rn!60!black, middle color = \Rn!80!black]
            ([xshift = -2mm]outertitle.north west) -- ([xshift = 2mm]outertitle.north east)[rounded corners = 1mm]
            -- ([xshift = 1mm, yshift = -1mm]outertitle.north east) -- (outertitle.south east) -- (outertitle.south west)
            -- ([xshift = -1mm, yshift = -1mm]outertitle.north west)
            [sharp corners] -- cycle;
            \node[text = white] at (outertitle) {Title #1};
        },
        overlay first = {\draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm]frame.south west)|-([yshift = 9mm]frame.north)-|
            ([xshift = 5mm]frame.south east);
            \coordinate (outernw) at ([shift = {(-5mm,1cm)}]frame.north west);  
            \node[fill=\Rn!70!black, minimum height = 5mm,
            anchor = north west, text = white, rounded corners] at ([xshift = 1cm]outernw) (outertitle) {Question #1};
            \path[fill = \Rn!30!black]
            ([yshift = -1mm, xshift = -1mm]outertitle.north west)
            arc[start angle = 0, end angle = 180, radius = 1mm]
            ([yshift = -1mm, xshift = 1mm]outertitle.north east)
            arc[start angle = 180, end angle = 0, radius = 1mm];
            \path[left color = \Rn!60!black, right color = \Rn!60!black, middle color = \Rn!80!black]
            ([xshift = -2mm]outertitle.north west) -- ([xshift = 2mm]outertitle.north east)[rounded corners = 1mm]
            -- ([xshift = 1mm, yshift = -1mm]outertitle.north east) -- (outertitle.south east) -- (outertitle.south west)
            -- ([xshift = -1mm, yshift = -1mm]outertitle.north west)
            [sharp corners] -- cycle;
            \node[text = white] at (outertitle) {Question #1};
        },
        overlay middle = {
            \draw[\Rn!70!black, line width = .8mm]
            ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
            ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
        },
        overlay last = {\draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm]frame.north west)|-([yshift = -5mm]frame.south)-|
            ([xshift = 5mm]frame.north east);
        }
}}

\tcbset{top/.style n args = {1}{enlarge top initially by = 1cm, enlarge bottom finally by = 1mm,
        enlarge left by = 5mm,
        enlarge right by = 5mm,
        width = \linewidth+2cm,
        overlay unbroken and first = {
            \draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm, yshift = -2mm]frame.south west)|-([yshift = 9mm]frame.north)-|
            ([xshift = 5mm, yshift = -2mm]frame.south east);
            \coordinate (outernw) at ([shift = {(-5mm,1cm)}]frame.north west);  
            \node[fill=\Rn!70!black, minimum height = 5mm,
            anchor = north west, text = white, rounded corners] at ([xshift = 1cm]outernw) (outertitle) {Title #1};
            \path[fill = \Rn!30!black]
            ([yshift = -1mm, xshift = -1mm]outertitle.north west)
            arc[start angle = 0, end angle = 180, radius = 1mm]
            ([yshift = -1mm, xshift = 1mm]outertitle.north east)
            arc[start angle = 180, end angle = 0, radius = 1mm];
            \path[left color = \Rn!60!black, right color = \Rn!60!black, middle color = \Rn!80!black]
            ([xshift = -2mm]outertitle.north west) -- ([xshift = 2mm]outertitle.north east)[rounded corners = 1mm]
            -- ([xshift = 1mm, yshift = -1mm]outertitle.north east) -- (outertitle.south east) -- (outertitle.south west)
            -- ([xshift = -1mm, yshift = -1mm]outertitle.north west)
            [sharp corners] -- cycle;
            \node[text = white] at (outertitle) {Title #1};
        },
        overlay middle and last = {
            \draw[\Rn!70!black, line width = .8mm]
            ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
            ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
}}}

\tcbset{middle/.style n args = {1}{enlarge top initially by = 1mm, enlarge bottom finally by = 1mm,
        enlarge left by = 5mm,
        enlarge right by = 5mm,
        width = \linewidth+2cm,
        overlay unbroken = {
            \draw[\Rn!70!black,line width = .8mm]
            ([shift = {(-5mm,3mm)}]frame.north west)--([shift = {(-5mm,-3mm)}]frame.south west)
            ([shift = {(5mm,3mm)}]frame.north east)--([shift = {(5mm,-3mm)}]frame.south east);
        },
        overlay first = {
            \draw[\Rn!70!black,line width = .8mm]
            ([shift = {(-5mm,5mm)}]frame.north west)--([xshift = -5mm]frame.south west)
            ([shift = {(5mm,5mm)}]frame.north east)--([xshift = 5mm]frame.south east);
        },
        overlay middle = {
            \draw[\Rn!70!black,line width = .8mm]
            ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
            ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
        },
        overlay last = {
            \draw[\Rn!70!black,line width = .8mm]
            ([xshift = -5mm]frame.north west)--([shift = {(-5mm,-5mm)}]frame.south west)
            ([xshift = 5mm]frame.north east)--([shift = {(5mm,-5mm)}]frame.south east);
        },
}}

\tcbset{bottom/.style = {enlarge bottom finally by = 7mm, enlarge top initially by = 1mm,
        enlarge left by = 5mm,
        enlarge right by = 5mm,
        width = \linewidth+2cm,
        overlay unbroken and last = {
            \draw[\Rn!70!black, line width = .8mm, rounded corners]
            ([xshift = -5mm, yshift = 2mm]frame.north west)|-([yshift = -5mm]frame.south)-|
            ([xshift = 5mm, yshift = 2mm]frame.north east);
        },
        overlay first and middle = {
            \draw[\Rn!70!black, line width = .8mm]
            ([xshift = -5mm]frame.north west)--([xshift = -5mm]frame.south west)
            ([xshift = 5mm]frame.north east)--([xshift = 5mm]frame.south east);
}}}

\newtcolorbox{generic}[5][]{empty,leftrule=\rulewidth,oversize, enhanced,
    frame style = {left color = #2!20, right color = white},interior style = {left color = #2!5, right color = white}, left = 0pt, right = 0pt, %top = 4pt, bottom = 4pt, 
    before skip = 0pt, after skip = 0pt,% boxrule = 0.1pt, 
    title = #3, underlay={\begin{tcbclipinterior}
            \shade[inner color = #2!10, outer color = white] (interior.north west) circle (2cm);
            \draw[help lines, step = 5mm, #2!5,shift={(interior.north west)}] (interior.south west) grid (interior.north east);
        \end{tcbclipinterior}
    }, drop small lifted shadow,
    breakable,rotate = \random
    ,
    frame code = {\path[tcb fill frame,rounded corners] (frame.south west)--(frame.north west) -- (frame.north east)--(frame.south east)--cycle;
    },
    interior code={\path[tcb fill interior,rounded corners] (interior.south west|-frame.south)--(interior.north west)--([xshift=-4.8mm]interior.north east)--([yshift=-4.8mm]interior.north east)--(interior.south east|-frame.south)--cycle;},
    % test
    setskinf = {#4},setskinm = {#4},setskinl = {#4},#5, #1}

\newcommand{\bllack}[3][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {normal = #2}
        #3
\end{generic}}

\newcommand{\tbllack}[3][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {top = #2}
        #3
\end{generic}}
\newcommand{\mbllack}[2][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {middle}
        #2
\end{generic}}
\newcommand{\bbllack}[2][]{\begin{generic}[#1]{bllack}{\bllackpicture}{cccoltria}
        {bottom}
        #2
\end{generic}}

\newcommand{\red}[3][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {normal = #2}
        #3
\end{generic}}
\newcommand{\tred}[3][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {top = #2}
        #3
\end{generic}}
\newcommand{\mred}[2][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {middle}
        #2
\end{generic}}
\newcommand{\bred}[2][]{
    \begin{generic}[#1]{red}{\redpicture}{cccccoltria}
        {bottom}
        #2
\end{generic}}

\newcommand{\bllue}[3][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {normal = #2}
        #3
\end{generic}}
\newcommand{\tbllue}[3][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {top = #2}
        #3
\end{generic}}
\newcommand{\mbllue}[2][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {middle}
        #2
\end{generic}}
\newcommand{\bbllue}[2][]{
    \begin{generic}[#1]{bllue}{\blluepicture}{coltria}
        {bottom}
        #2
\end{generic}}

\newcommand{\tcblowerr}{\begin{tcblowerbox}%{middle}
        \tcblower
\end{tcblowerbox}}

\begin{document}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \red{{8}}{\lipsum[1-1]}
    %   
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-2]}
    \red{{8}}{\lipsum[1-1]}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %
    \tbllack{1}{\lipsum[1-1]}
    \mred{\lipsum[1-1]}
    \bbllue{\lipsum[1-1]}
    \tbllack{2}{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-1]}
    \red{{8}}{\lipsum[1-1]}
    %   
    %\newpage
    %\section{Title}
    \bllue{3}{\lipsum[1-1]}
    \tred{4}{\lipsum[1-1]}
    \mbllue{\lipsum[1-1]}
    \bbllack{\lipsum[1-1]}
    \bllack{6}{\lipsum[1-1]}
    %   
    \tbllue{7}{\lipsum[1-1]}
    \mbllack{\lipsum[1-1]}
    \bred{\lipsum[1-2]}
    \red{{8}}{\lipsum[1-1]}

\end{document}

enter image description here

  • @Ignasi, my second problem has been solved, thanks for your advice! :D But do you have tips for my first question? – Faceb Faceb Jun 19 '18 at 21:56