表格下方和旁边的水平和垂直括号

表格下方和旁边的水平和垂直括号

我需要将 Power Point 中制作的一些内容复制到 Latex 投影仪中。一些幻灯片包含各种大小和排列的括号和文本气泡。由于我对整个 Latex 还不熟悉,到目前为止我可能只是把它弄乱了(对此我很抱歉)。我只是真的想知道一种比用 tikz 手动定位这些括号和文本气泡更好的方法来排列它们,因为这是我必须多次执行的操作。此外,我找不到让垂直括号以与示例中类似的方式工作的方法。非常感谢您的帮助。

编辑:我真的很喜欢将 \tikzmark{} 放在某处并将其用作锚点的想法。

期望的结果: 结果

到目前为止,我的方法主要是从一些类似的问题中复制而来的(没有颜色和其他东西以保持其简洁):

迄今为止

\documentclass[presentation, aspectratio=1610, 12pt, t]{beamer}
\usepackage{tikz} 
\usetikzlibrary{cd,arrows, decorations.markings, backgrounds, shapes.multipart,matrix,positioning, shapes, fit,decorations.pathreplacing,angles,quotes,decorations.pathreplacing,calc}

\usepackage{multirow} %adds the possibility to create columns spanning mulitple rows

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand*{\BraceAmplitude}{0.5em}%  Can be tweaked if
\newcommand*{\VerticalOffset}{1.2ex}%  necessary.
\newcommand*{\HorizontalOffset}{0.8ex}%  necessary.
\newcommand*{\InsertUnderBrace}[4][]{%
    \begin{tikzpicture}[overlay,remember picture]
\draw [decoration={brace,amplitude=\BraceAmplitude},decorate, thick,draw=black,text=black,#1]
        ($(#3)+(\HorizontalOffset,-\VerticalOffset)$) -- 
        ($(#2)+(-\HorizontalOffset,-\VerticalOffset)$)
        node [below=\VerticalOffset, midway] {#4};
    \end{tikzpicture}%
}%

\begin{document}
\begin{frame}
\begin{tabular}{l l l l l l | l}
    1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \hline
    A & test & 2 & U & 14 & A & \\ 
    A & test & 2 & U & 14 & A & \multirow{ -2}{*}{L1} \\ 
    A & test & 2 & U & 14 & A & \\
    A & test & 2 & U & 14 & A &  \\
    A & test & 2 & U & 14 & A &  \\
    A & test & 2 & U & 14 & A &  \multirow{ -4}{*}{L2} \\
    \tikzmark{start1}...&...&...&...&...&...{ }\tikzmark{end1}&\tikzmark{start2}... \tikzmark{end2}\\
\end{tabular}
\normalsize

\InsertUnderBrace[draw=black,text=black]{start1}{end1}{Pretty loooong text here
}
\InsertUnderBrace[draw=black,text=black]{start2}{end2}{Explanation}

\tikz\draw [remember picture,overlay,thick, black,decorate,decoration={brace,amplitude=10pt,mirror},xshift=0pt,yshift=0pt](3,-1) -- (8,-1) node[black,midway,yshift=-0.6cm] {\footnotesize $Made with tikz$};
\end{frame}
\end{document}

答案1

稍微复杂一点,如图tikz

在此处输入图片描述

\documentclass[presentation, aspectratio=1610, 12pt, t]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows,
                calc,
                decorations.pathreplacing,
                calligraphy,% had to be after decorations.pathreplacing
                matrix,
                positioning
                }

\begin{document}
\begin{frame}[fragile]
\[
    \begin{tikzpicture}[
node distance = 0pt,
    BC/.style = {
        decorate,
        decoration={calligraphic brace, amplitude=1.2mm,
        pre =moveto, pre  length=0.75pt,
        post=moveto, post length=0.75pt,
        raise=1mm,
        #1},% for mirroring of brace
        very thick,
        pen colour={red}% black ...
                  },
  BC/.default = mirror,
    LN/.style = {inner xsep=4pt, outer sep=0pt},
                        ]
\matrix (m) [matrix of nodes, inner sep=0pt,
             nodes={text depth=0.8ex, text height=1em, %minimum width=5ex,
                    inner ysep=1pt, inner xsep=4pt, outer sep=0pt, anchor=west},
             nodes in empty cells,
             column sep=-\pgflinewidth,
             row sep= -\pgflinewidth,
             ]
{
    1   & 2     & 3     & 4     & 5     & 6     & 7     \\
    A   & test  & 2     & U     & 14    & A     &       \\
    A   & test  & 2     & U     & 14    & A     &       \\
    A   & test  & 2     & U     & 14    & A     &       \\
    A   & test  & 2     & U     & 14    & A     &       \\
    A   & test  & 2     & U     & 14    & A     &       \\
    A   & test  & 2     & U     & 14    & A     &       \\
\dots   & \dots & \dots & \dots & \dots & \dots & \dots \\
};
\node[LN,right=of m-2-6.south -| m-1-7.west] {L1};
\node[LN,right=of m-5-6.south -| m-1-7.west] {L2};
\draw           (m-1-1.south west) -- (m-1-7.south east);
\draw[BC={}]    (m-2-7.north -| m.east) --
                    node[right=3mm] {bla bla 1}
                (m-3-7.south -| m.east);
\draw[BC={}]    (m-4-7.north -| m.east) --
                    node[right=3mm] {bla bla 2}
                (m-7-7.south -| m.east);
%
\draw[BC]   let \p1 = ($(m-1-1.west)-(m-1-6.east)$),
                \n1 = {veclen(\x1,\y1)} in
            (m-8-1.south west) --
                node[text width=\n1, align=center,
                     below=3mm] {Pretty loooong loooong loooong loooong loooong loooong loooong loooong text here}
            (m-8-6.south east)
                    ;
\draw[BC]   (m-8-7.south west) --
                node[align=center, below=3mm] {Expla- \\
                                               nation}
            (m-8-7.south east);
    \end{tikzpicture}
\]
\end{frame}
\end{document}

答案2

一个简单的答案(快速测试):使用小页面!

\InsertUnderBrace[draw=black,text=black]{start1}{end1}{\begin{minipage}{3cm}Pretty loooong text here\end{minipage}}
\InsertUnderBrace[draw=black,text=black]{start2}{end2}{Explanation}

相关内容