0

I am trying to make two subtables side by side, but I don't know why the second one is below the first table. I searched around the similar questions, but still have no clue. Can someone help me fix it? Thanks!

\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}```

GZS
  • 45
  • have a look at a similar question -- https://tex.stackexchange.com/questions/294589/alignment-and-placing-of-subtables – js bibra Jul 18 '21 at 02:42

1 Answers1

2

enter image description here

\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}

js bibra
  • 21,280