我正在尝试在表格列的顶部放置两个括号,如下图所示。我发现了一个类似的问题这里bigdelim package
并在答案中建议使用。
我尝试使用过度支撑但它对我不起作用或者我没有正确使用它。
下面举一个例子来说明这个问题:
\begin{document}
\documentclass{article}
\usepackage{multirow}
\usepackage{graphicx}
\begin{table}[]
\centering
\caption{}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{cccccclccccl}
\multicolumn{1}{l}{} &
{\overbrace\multicolumn{6}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Case study:1\\ (check 1)\end{tabular}}}} &
{\overbrace\multicolumn{5}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Case study:2\\ (check 2)\end{tabular}}}} \\ \hline
\multicolumn{1}{|l|}{Method} &
\multicolumn{1}{l|}{Class} &
\multicolumn{1}{l|}{cat} &
\multicolumn{1}{l|}{ball} &
\multicolumn{1}{l|}{ali} &
\multicolumn{1}{l|}{micheal} &
\multicolumn{1}{l|}{tara} &
\multicolumn{1}{l|}{cat} &
\multicolumn{1}{l|}{ball} &
\multicolumn{1}{l|}{ali} &
\multicolumn{1}{l|}{micheal} &
\multicolumn{1}{l|}{tara} \\ \hline
\multicolumn{1}{|c|}{\multirow{4}{*}{kk}} &
\multicolumn{1}{c|}{R} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \cline{2-12}
\multicolumn{1}{|c|}{} &
\multicolumn{1}{c|}{C} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \cline{2-12}
\multicolumn{1}{|c|}{} &
\multicolumn{1}{c|}{T} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \cline{2-12}
\multicolumn{1}{|c|}{} &
\multicolumn{1}{r|}{\textbf{Average:}} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \hline
\end{tabular}%
}
\end{table}
\end{document}
答案1
\documentclass{article}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\begin{table}[]
\centering
\caption{}
\vspace{\baselineskip}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{cccccclccccl}
& & \multicolumn{5}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Case study:1\\ (check 1)\end{tabular}}} &
\multicolumn{5}{c}{\textbf{\begin{tabular}[c]{@{}c@{}}Case study:2\\ (check 2)\end{tabular}}} \\
& & \multicolumn{5}{c}{\downbracefill} & \multicolumn{5}{c}{\downbracefill} \\
\hline
\multicolumn{1}{|l|}{Method} &
\multicolumn{1}{l|}{Class} &
\multicolumn{1}{l|}{cat} &
\multicolumn{1}{l|}{ball} &
\multicolumn{1}{l|}{ali} &
\multicolumn{1}{l|}{micheal} &
\multicolumn{1}{l|}{tara} &
\multicolumn{1}{l|}{cat} &
\multicolumn{1}{l|}{ball} &
\multicolumn{1}{l|}{ali} &
\multicolumn{1}{l|}{micheal} &
\multicolumn{1}{l|}{tara} \\ \hline
\multicolumn{1}{|c|}{\multirow{4}{*}{kk}} &
\multicolumn{1}{c|}{R} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \cline{2-12}
\multicolumn{1}{|c|}{} &
\multicolumn{1}{c|}{C} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \cline{2-12}
\multicolumn{1}{|c|}{} &
\multicolumn{1}{c|}{T} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \cline{2-12}
\multicolumn{1}{|c|}{} &
\multicolumn{1}{r|}{\textbf{Average:}} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{c|}{} &
\multicolumn{1}{l|}{} \\ \hline
\end{tabular}%
}
\end{table}
\end{document}
答案2
以下是您可以使用(≥ 6.4,截至 2021-11-23)做{NiceTabular}
的事情。nicematrix
\documentclass{article}
\usepackage{geometry}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}{*{12}{c}}
\RowStyle[bold]{}
& & \Block{1-5}{Case study:1\\ (check 1)} &&&&&
\Block{1-5}{Case study: 2\\ (check 2)} \\
\\
\Block[hvlines]{*-*}{}
Method & Class & cat & ball & ali & micheal & tara & cat & ball & ali & micheal & tara \\
\Block{4-1}{kk} & R \\
& C \\
& T \\
& \textbf{Average:} \\
\CodeAfter
\OverBrace[yshift=1mm,shorten]{3-3}{3-7}{}
\OverBrace[yshift=1mm,shorten]{3-8}{3-12}{}
\end{NiceTabular}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。