子表没有并排对齐

子表没有并排对齐

我正在尝试并排创建两个子表,但我不知道为什么第二个子表位于第一个表下方。我搜索了类似的问题,但仍然毫无头绪。有人能帮我解决这个问题吗?谢谢!

\usepackage[letterpaper,margin=2cm]{geometry} % set page parameters suitably
\usepackage{booktabs,subcaption,graphicx}

\begin{document}

\begin{table}[h]

\begin{subtable}[t]{0.45\textwidth}
\begin{tabular}[t]{@{} l *{2}{c} @{}}
\toprule
 & {Ambiguous} & {Unambiguous}  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-1 blablablablablablabla}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-2}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-3}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645 \\
split-3 &  21477 &  25166  \\
\bottomrule
\end{tabular}
\end{subtable}%

\begin{subtable}[t]{0.45\textwidth}
\flushright
\begin{tabular}[t]{@{} l *{2}{c} @{}}
\toprule
 & {Ambiguous} & {Unambiguous}  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-1 blablablablablablabla}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-2}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-3}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645 \\
split-3 &  21477 &  25166  \\
\bottomrule
\end{tabular}
\end{subtable}

\caption{Model parameters.}
\label{tab:parameters}

\end{table}

\end{document}```

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs,subcaption,amsfonts,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}

\begin{table}
\begin{subtable}[t]{0.48\textwidth}
\begin{tabular}[t]{@{} l *{2}{c} @{}}
\toprule
 & {Ambiguous} & {Unambiguous}  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-1 blablablablablablabla}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-2}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-3}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645 \\
split-3 &  21477 &  25166  \\
\bottomrule
\end{tabular}
\end{subtable}%
\hspace{\fill}
\begin{subtable}[t]{0.48\textwidth}
\flushright
\begin{tabular}[t]{@{} l *{2}{c} @{}}
\toprule
 & {Ambiguous} & {Unambiguous}  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-1 blablablablablablabla}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-2}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645  \\
split-3 &  21477 &  25166  \\
\midrule
\multicolumn{3}{@{}l}{\textit{Dataset-3}} \\
split-1 & 170266 & 197630  \\
split-2 &  21479 &  24645 \\
split-3 &  21477 &  25166  \\
\bottomrule
\end{tabular}
\end{subtable}


\caption{Model parameters.}
\label{tab:parameters}
\end{table}
\end{document}

相关内容