4

I have a text in a tcolorbox for some part of it I want to give some explanations. Please see MWE below. I have some questions (please feel free to answer anyone of them, not all):

  1. How can I insert a right curly bracket for some lines of the text as shown in the picture?
  2. How can I align vertically in middle of tcolorbox explanation 3?
  3. Can I align arrows (tikz made) relatively to tcolorbox as we can do in current.page?
\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{ulem,varwidth}
\usepackage{tikz}

\begin{document}
    \begin{tcolorbox}[enhanced,
        before skip=2mm,after skip=2mm,
        colback=black!5,colframe=black,boxrule=0.5mm,
        attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight},
        varwidth boxed title*=-3cm,sidebyside,lefthand width=11cm,
        boxed title style={frame code={
                \path[fill=tcbcolback!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=tcbcolback!10!black!40,right color=tcbcolback!10!black!40,
                middle color=tcbcolback!90!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,adjusted title={Title 1:},fonttitle=\bfseries,colback=gray!20,colbacktitle=gray!50,coltitle=black,parbox=false,right=4mm]
        
        \begin{tcolorbox}[width=10cm]
            This is explanation 1 for the first sentence of the text below.
        \end{tcolorbox}
        
        \begin{tikzpicture}[xshift=5cm]
            \draw[line width=2pt,->] (0,0)   (4,0) -- (4,1);
        \end{tikzpicture}
        
        \uline{This is the first sentence of text and we have for this sentence explanation 1.} Here we have some text which expands in several lines and we would like to include these lines into a right big curly bracket, but the first and last sentence we don't want to be included in this bracket. Is it that possible? \uline{This is the last sentence of the text and we have for this sentence explanation 2}.
        
        \begin{tikzpicture}
            \draw[line width=2pt,->] (0,0)   (4,0) -- (4,-1);
        \end{tikzpicture}
        \begin{tikzpicture}[overlay,remember picture]
            \draw[line width=2pt,->] (0,0)   (6.5,3) -- (7.2,3);
        \end{tikzpicture}
        
        \begin{tcolorbox}[width=10cm]
            This is explanation 2 for the last sentence of the above text.
        \end{tcolorbox}
        
        \tcblower
        
        \begin{tcolorbox}[width=5cm]
            
            \uline{\textbf{Explanation 3}}
            
            This is explanation 3 which gives informaion about the text that is included in the right curly bracket
        \end{tcolorbox}
    \end{tcolorbox}
\end{document}

enter image description here

1 Answer 1

7

I would make use of \tikzmarks and use them also to draw the three arrows. You can use the remember as option provided by the tcolorbox package to refer to boxes later in your code. Boxes need to be enhanced to be able to take this option.

\documentclass[12pt]{article}
\usepackage[a4paper, total={180mm,257mm},left=15mm,top=20mm]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{ulem,varwidth}
\usetikzlibrary{tikzmark, decorations.pathreplacing}

\begin{document}
    \begin{tcolorbox}[
        enhanced,
        before skip=2mm, after skip=2mm,
        colback=black!5, colframe=black, boxrule=0.5mm,
        attach boxed title to top left={xshift=1cm, yshift*=1mm-\tcboxedtitleheight},
        varwidth boxed title*=-3cm, sidebyside, lefthand width=11cm,
        boxed title style={
            frame code={
                \path[fill=tcbcolback!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=tcbcolback!10!black!40, right color=tcbcolback!10!black!40, middle color=tcbcolback!90!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, adjusted title={Title 1:}, 
        colback=gray!20, colbacktitle=gray!50, coltitle=black, 
        parbox=false, right=4mm
    ]
        
        \begin{tcolorbox}[enhanced, width=10cm, remember as=explanation one]
            This is explanation 1 for the first sentence of the text below.
        \end{tcolorbox}

        \bigskip
        
        \tikzmark{top} \uline{This is the first sentence of text and we have for this sentence explanation 1.} \tikzmark{start} Here we have some text which expands in several lines and we would like to include these lines into a right big curly bracket, but the first and last sentence we don't want to be included in this bracket. Is it that possible? \tikzmark{end} \uline{This is the last sentence of the text and we have for this sentence explanation 2}. \tikzmark{bottom}
        
        \bigskip

        \begin{tcolorbox}[enhanced, width=10cm, remember as=explanation two]
            This is explanation 2 for the last sentence of the above text.
        \end{tcolorbox}
        
        \tcblower
        
        \begin{tcolorbox}[enhanced, width=5cm, remember as=explanation three]
            \uline{\textbf{Explanation 3}}
            This is explanation 3 which gives informaion about the text that is included in the right curly bracket
        \end{tcolorbox}
    \end{tcolorbox}
    
    \begin{tikzpicture}[overlay, remember picture]
        \draw[line width=2pt, ->, shorten >=5pt, shorten <=5pt] 
            ([yshift=1ex]explanation one.south |- {pic cs:top}) -- (explanation one.south);
        \draw[line width=2pt, ->, shorten >=5pt, shorten <=5pt] 
            (explanation two.north |- {pic cs:bottom}) -- (explanation two.north);
        \draw[line width=2pt, decorate, decoration={brace, amplitude=5pt}] 
            ([xshift=-2em, yshift=1ex]explanation three.west |- {pic cs:start}) -- 
            ([xshift=-2em]explanation three.west |- {pic cs:end});
        \draw[line width=2pt, ->, shorten >=5pt, shorten <=5pt] 
            ([xshift=-2em]explanation three.west) -- (explanation three.west);
    \end{tikzpicture}
    
\end{document}

enter image description here

You must log in to answer this question.

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