如何为多行文本插入右花括号(无数学)?

如何为多行文本插入右花括号(无数学)?

我有一段文字,tcolorbox我想对其中的一部分做出一些解释。请参阅下面的 MWE。我有一些问题(请随意回答其中任何一个,不是全部):

  1. 如何为文本的某些行插入右花括号,如图所示?
  2. 我怎样才能在解释 3 的中间垂直对齐tcolorbox
  3. 我可以将箭头(tikz 制作)相对对齐,tcolorbox正如我们在 中所做的那样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}

在此处输入图片描述

答案1

我会使用\tikzmarks 并用它们绘制三个箭头。您可以使用包remember as提供的选项tcolorbox在代码中引用方框。方框需要enhanced能够采用此选项。

\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}

在此处输入图片描述

相关内容