答案1
像这样?请注意,根据设计,8 个底层列的宽度是相等的。
\documentclass{article} % or some other suitable document classs
\usepackage{array} % for 'w' column type
\usepackage{calc}
\newlength\mylen
\begin{document}
\begin{table}
\renewcommand\arraystretch{2} % default: 1
\small % optional
% calculate usable col. width:
\setlength\tabcolsep{2pt} % default: 6pt
\setlength\mylen{(\textwidth-16\tabcolsep-9\arrayrulewidth)/8}
\begin{tabular}{| *{8}{w{c}{\mylen}|} }
\hline
\multicolumn{8}{|c|}{Ensemble Model} \\
\hline
\multicolumn{4}{|c|}{Binary Classification} &
\multicolumn{4}{ c|}{Multiclass Classification} \\
\hline
Accuracy & Precision & Recall & F1 Score & Accuracy & Precision & Recall & F1 Score \\
\hline
99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 \\
\hline
\end{tabular}
\caption{Accuracy of Ensemble Model Architecture}
\end{table}
\end{document}
答案2
我会建议表格数组。它有一个相当简单的界面来制作更复杂的表格。所讨论的那个很简单,但你可能想要合并单元格、拉伸行或自定义栏和规则,然后表格数组可以更轻松地实现目标。还可以方便地tabularray
将表示与数据分开。
您可以用首字母缩略词替换较长的单词,并在表格底部添加解释,以避免表格太宽。
下面是两个例子。第一个几乎完全照搬了你的。另一个是提出并证明了表格数组。
我注意到了两个细节。该表由两个单独的表组成。将它们垂直堆叠不是更容易吗?您还在标题和表中重复了“Ensemble”一词,并且可能使第一行变得多余。这是我的个人看法。
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{table}[tbh]
\begin{tblr}{
width = \textwidth,
stretch = 1.5,
colspec = {*{8}{X[c,m]}},
columns = {colsep=2pt},
cell{1}{1} = {c=8}{},
cell{2}{1} = {c=4}{}, cell{2}{5} = {c=4}{},
cells = {font = \small},
hlines, vlines,
}
Ensemble Model & & & & & & & \\
Binary Classification & & & & Multiclass Classification & & & \\
Accuracy & Precision & Recall & F1 Score
& Accuracy & Precision & Recall & F1 Score \\
99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 \\
\end{tblr}
\caption{Accuracy of Ensemble Model Architecture}
\label{tab:yoursection:accuracy-ensemble-model-arch1}
\end{table}
\bigskip
\begin{table}[tbh]
\caption{Accuracy of Ensemble Model Architecture}\vspace{6pt}
\label{tab:yoursection:accuracy-ensemble-model-arch}
\begin{tblr}
%%% Presentation
{
width = \textwidth,
stretch = 1.15,
colspec = {*{8}{X[c,m]}},
% Column specification
columns = {colsep=2pt},
column{4} = {rightsep=6pt},
column{5} = {leftsep=6pt},
% Row specification
row{1} = {rowsep = 6pt},
row{2} = {abovesep = 6pt},
row{Z} = {rowsep=0pt},
% Cell specification
cell{1}{1} = {c=8}{},
cell{Z}{1} = {c=8}{
halign=l, font=\footnotesize,
},
cell{2}{1,5} = {c=4}{},
% Rule specification
hline{1,Y} = {0.8pt},
hline{2} = {0.5pt},
hline{3-4} = {1-4}{0.3pt,rightpos=-1,endpos},
hline{3-4} = {5-8}{0.3pt,leftpos=-1,endpos},
}
%%% Data
Ensemble Model & & & & & & & \\
Binary Classification & & & & Multiclass Classification & & & \\
A & P & R & F1 & A & P & R & F1 \\
99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 & 99.99 \\
A: Accuracy,\quad P: Precesion,\quad R: Recall,\quad F1: F1 Score
\end{tblr}
\end{table}
\end{document}