The goal is to place a brackets into the table (longtable
) to embrace some rows of this table:
The solution which involves rdelim
and \multirows
command (described here: usage of \rdelim
) gives not uniform bracket widths as well as not uniform bracket line widths while distinct brackets have various span: \rdelim
example
So the natural solution of the problem is usage of putting "remembered pictures" into the table and spanning brackets that are "decorations": decorations in \longtable
But the problem is that the nodes can travel to the next page:
What to do, to prevent nodes against escaping to the next page?
The solution given for mathematical formulas (forcing nodes to not travel to the next page) does not work here.
MWE:
\documentclass[12pt,a5paper,twoside]{article}
\usepackage[polish]{babel}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{tikz}
\usepackage[a5paper]{geometry}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{longtable}{p{3cm}p{3cm}}
\toprule
first column & second column\tikz [remember picture] \node (rightmark) {};\\
\midrule
\endhead
A & A \\
A & A \\
A & A \\
A & A \\
A & A \\
A & A \\
A & A \\
A & A \\
A & A \\
B & B \tikz [remember picture] \node (n1) {};\\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \\*
B & B \tikz [remember picture] \node (n2) {};\\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
C & C \\
\bottomrule
\end{longtable}
% curly brace
\tikz [overlay,remember picture]
\draw [decoration={brace,amplitude=2mm},decorate,thick]
(n1.north -| rightmark) -- (n2.south -| rightmark)
node [midway,right=4mm,align=left] {The bracket\\spanned on\\some rows};
\end{document}