![用花括号总结表格的各个部分](https://linux22.com/image/304713/%E7%94%A8%E8%8A%B1%E6%8B%AC%E5%8F%B7%E6%80%BB%E7%BB%93%E8%A1%A8%E6%A0%BC%E7%9A%84%E5%90%84%E4%B8%AA%E9%83%A8%E5%88%86.png)
我想创建一个表格(参见附图)并使用曲线图来总结一些单元格。
我做了很多研究,找到了这个解决方案(表格周围的花括号),但它对我没有太大帮助,因为它只是数学内容,我只想输入文本。
有人知道如何优雅地解决这个问题吗?
干杯
答案1
这是一个tikzmark
使用 2 个参数brace decoration
和link
3 个参数的宏的解决方案。
代码
\documentclass[border=30pt]{standalone}
\usepackage{tikz,array,calc}
\usetikzlibrary{decorations.pathreplacing}
\newcommand\tikzmark[2]{%
\tikz[remember picture,overlay]
\node[inner sep=0pt,outer sep=2pt] (#1){#2};%
}
\newcommand\link[3]{%
\begin{tikzpicture}[remember picture, overlay]
\draw [decorate,decoration={brace,amplitude=5pt,raise=1pt}]
(#1.north west)--(#2.north east)node[above=10pt,midway]{#3};
\end{tikzpicture}%
}
\def\cwidth{1.5cm} % change this for column width
\begin{document}
\noindent
\begin{tabular}{m{\cwidth}|m{\cwidth}|m{\cwidth}|m{\cwidth}|}
\multicolumn{1}{l}{}
&\multicolumn{1}{c}{\tikzmark{b}{\makebox[\cwidth][c]{Fish}}}
&\multicolumn{1}{c}{\tikzmark{c}{\makebox[\cwidth][c]{Mouse}}}
&\multicolumn{1}{c}{\tikzmark{d}{\makebox[\cwidth][c]{Bird}}}\\ [1ex]\cline{2-4}
Apple & Here is a sample of text describing an apple&Some text here & some text\\ \cline{2-4}
Banana & Here is a sample of text describing a banana & & \\ \cline{2-4}
\end{tabular}
\link{b}{c}{Category A}
\link{d}{d}{Category B}
\end{document}