2

I would like to create a table (cf. attached figure) and use curly brakes to summarize some of the cells.

enter image description here

I did a lot of research and found this solution (Curly brackets around a table), but it doesn't help me much as it is only math content and I would like to enter text only.

Does anyone have an idea about how to solve this problem elegantly?

Cheers

1

This is one solution where tikzmark taking 2 arguments, brace decoration and link macro that takes 3 arguments are used.

enter image description here

Code

\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}
| improve this answer | |
  • Looks great and works very well, thank you for your reply! – Mil Jan 30 '15 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.