# subtable alignment

I am struggling to align two tables using the subcaption package. I have seen answers to this question that rely on tabular* but my tables are produced by a stats software that convert regression output into tabular and I want to avoid messing around with them.

The basic flavor of the tables is this:

\begin{table}[H]
\centering
\caption{Table}
\begin{subtable}[b]{0.5\linewidth}
\centering
\caption{subtable 1}
\resizebox{\linewidth}{!}{%
{
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\begin{tabular}{l*{4}{c}}
\toprule
&\multicolumn{2}{c}{Group A}               &\multicolumn{2}{c}{Group B}              \\\cmidrule(lr){2-3}\cmidrule(lr){4-5}
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
&\multicolumn{1}{c}{Control}&\multicolumn{1}{c}{Treatment}&\multicolumn{1}{c}{Control}&\multicolumn{1}{c}{Treatment}\\
\midrule
Condition          &      a        &      b        &      c        &      d\\
&      (a)         &      (b)         &      (c)         &      (d)         \\
Constant (No condition)            &      e&      f&      g&      h\\
&      (e)         &      (f)         &      (g)         &      (h)         \\
\midrule
Observations        &         N         &         N         &         N         &         N         \\
\bottomrule
\multicolumn{5}{l}{\footnotesize Standard errors clustered at the group level.}\\
\multicolumn{5}{l}{\footnotesize \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$}\\
\end{tabular}
}}
\end{subtable}
\begin{subtable}[b]{0.5\linewidth}
\centering
\caption{subtable 2}
\resizebox{\linewidth}{!}{%
{
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}
\begin{tabular}{l*{4}{c}}
\toprule
&\multicolumn{2}{c}{Group A}               &\multicolumn{2}{c}{Group B}              \\\cmidrule(lr){2-3}\cmidrule(lr){4-5}
&\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
&\multicolumn{1}{c}{Control}&\multicolumn{1}{c}{Treatment}&\multicolumn{1}{c}{Control}&\multicolumn{1}{c}{Treatment}\\
\midrule
Condition          &      a        &      b        &      c        &      d\\
&      (a)         &      (b)         &      (c)         &      (d)         \\
Constant (No condition)            &      e&      f&      g&      h\\
&      (e)         &      (f)         &      (g)         &      (h)         \\
\midrule
Observations        &         N         &         N         &         N         &         N         \\
\bottomrule
\multicolumn{5}{l}{\footnotesize Standard errors clustered at the group level.}\\
\multicolumn{5}{l}{\footnotesize \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$}\\
\end{tabular}
}}
\end{subtable}
\end{table}


When I try to introduce horizontal space (e.g. using \hspace*{\fill}) and change the space allocated for each subtable (e.g. {0.45\linewidth}) I get an overlapping monstrosity.

This was a bit simpler with the subfig package, but I have been told that subcaption is now the way to go.

• Put a % (comment) symbol immediately after the first instance of \end{subtable}. – Mico Aug 6 at 17:33
• Could you please make your example code compilable? Please also reconsider your usage of resizebox as this will lead to inconsistent (and in your case most likely also very small) font sizes. – leandriis Aug 6 at 17:40

The reason the subtable environments, each of width 0.5\linewidth, currently don't seem to want to be placed side by side is that you've written \end{subtable} rather than \end{subtable}%. The lack of a % (comment) character after the first \end{subtable} statement means that a bit of whitespace gets inserted which, in turn, pushes the second subtable to the next row.

Your code also suffers from an abundance of pointless, but highly clutter-y, \multicolumn{1}{c}{...} wrapper statements in colums 2 thru 5. Since the column types of all four data columns is c, the wrappers do absolutely nothing. Get rid of them.

I would also get rid of (or, at least, comment out) the three \centering statements: They, too, do nothing -- except create code clutter.

In order to keep the \resizebox statements from miniaturizing their arguments excessively, do think long and hard about making the columns -- and especially the header columns -- less wide. E.g., don't place Constant (No condition) all on one line. You will get far more pleasing results if you place (No condition) on the next line. Other ways of reducing unneeded horizontal expanse (which has to be sized down via \resizebox) are (a) get rid of the whitespace adding on either end of the tabular environments and (b) reduce the value of \tabcolsep, the parameter that governs the amount of intercolumn whitespace.

Implementing these suggestions, and setting the widths of the subtable environments to 0.485\linewidth (and inserting an \hfill instruction), one obtains the following output:

\documentclass{article}
\usepackage[letterpaper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{booktabs,subcaption,graphicx}
\def\sym#1{\ifmmode^{#1}\else$$^{#1}$$\fi}

\begin{document}
\begin{table}[h!]
\setlength\tabcolsep{4pt} % default value: 6pt
%\centering
\caption{Table}
\begin{subtable}[t]{0.485\linewidth}
%\centering
\caption{subtable 1}
\resizebox{\linewidth}{!}{%
\begin{tabular}{@{} l *{4}{c} @{}}
\toprule
&\multicolumn{2}{c}{Group A}
&\multicolumn{2}{c@{}}{Group B}\\
\cmidrule(lr){2-3}\cmidrule(l){4-5}
& (1) & (2) & (3) & (4)\\
&Control&Treatment&Control&Treatment\\
\midrule
Condition        & a & b & c & d\\
& (a) & (b) & (c) & (d) \\
Constant         & e & f & g & h\\
\ \ [No condition] & (e) & (f) & (g) & (h) \\
\midrule
Observations        & N & N & N & N \\
\bottomrule
\multicolumn{5}{@{}l}{\footnotesize Standard errors clustered at the group level.}\\
\multicolumn{5}{@{}l}{\footnotesize \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$}\\
\end{tabular}%
}%
\end{subtable}%
\hfill % maximize the horizontal separation
\begin{subtable}[t]{0.485\linewidth}
%\centering
\caption{subtable 2}
\resizebox{\linewidth}{!}{%
\begin{tabular}{@{} l *{4}{c} @{}}
\toprule
&\multicolumn{2}{c}{Group A}
&\multicolumn{2}{c@{}}{Group B} \\
\cmidrule(lr){2-3}\cmidrule(l){4-5}
& (1) & (2) & (3) & (4)\\
&Control&Treatment&Control&Treatment\\
\midrule
Condition        & a & b & c & d\\
& (a) & (b) & (c) & (d) \\
Constant         & e & f & g & h\\
\ \ [No condition] & (e) & (f) & (g) & (h) \\
\midrule
Observations        & N & N & N & N \\
\bottomrule
\multicolumn{5}{@{}l}{\footnotesize \sym{*} $$p<0.10$$, \sym{**} $$p<0.05$$, \sym{***} $$p<0.01$$}\\