![子表没有并排对齐](https://linux22.com/image/436860/%E5%AD%90%E8%A1%A8%E6%B2%A1%E6%9C%89%E5%B9%B6%E6%8E%92%E5%AF%B9%E9%BD%90.png)
我正在尝试并排创建两个子表,但我不知道为什么第二个子表位于第一个表下方。我搜索了类似的问题,但仍然毫无头绪。有人能帮我解决这个问题吗?谢谢!
\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}