# Help aligning tables.

I need to align 1 table to the right and two to the left, the layout I want to achieve is something like this:

\begin{figure}
\centering
\subfloat[]{%
\begin{tabular}[b]{cc}
\hline
0 & 1\\
\hline
2 & 1\\
3 & 1\\
4 & 2\\
5 & 3\\
4 & 8\\
\hline
\end{tabular}%
\subfloat[]{%
\begin{tabular}[b]{ccc}
\hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\
\hline
\end{tabular}%
\begin{tabular}[b]{ccc}
\hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\
\hline
\end{tabular}%
}~
\end{figure}


Ted.

-

A solution for both variants, two and three subfloats

\documentclass{article}
\usepackage{subfig}
\begin{document}

\begin{table}
\minipage[b]{0.49\linewidth}
\centering
\subfloat[]{%
\begin{tabular}[b]{cc}\hline
0 & 1\\\hline
2 & 1\\
3 & 1\\
4 & 2\\
5 & 3\\
4 & 8\\\hline
\end{tabular}}%
\subfloat[]{%
\begin{tabular}[b]{@{}c@{}}%
\begin{tabular}{ccc} \hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\\hline
\end{tabular}\\[5ex]
\begin{tabular}[b]{ccc} \hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4
\end{tabular}\\\hline
\end{tabular}}%
\caption{the one for all}

\endminipage\hfill
\minipage[b]{0.49\linewidth}
\centering
\subfloat[]{%
\begin{tabular}[b]{cc}\hline
0 & 1\\\hline
2 & 1\\
3 & 1\\
4 & 2\\
5 & 3\\
4 & 8\\\hline
\end{tabular}}%
\begin{tabular}[b]{c}%
\subfloat[]{%
\begin{tabular}{ccc} \hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\\hline
\end{tabular}}\\[5ex]
\subfloat[]{%
\begin{tabular}[b]{ccc} \hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\\hline
\end{tabular}}%
\end{tabular}%

\caption{the one for all}
\endminipage
\end{table}

\end{document}

-
This works fine on its own, but when the \subfloat captions are added the right one is further down than the left caption. Added the parent tabular on the left fixes that. –  Martin Scharrer Feb 1 '11 at 11:53
@Martin: no, then you did something wrong ... –  Herbert Feb 1 '11 at 11:59
To clarify: the tables are still aligned correctly, but not the sublabels created by \subfloat. The reason seems to be the extra space caused by the bottom \hline s. After removing them in the both left and bottom right tabular the sublabels are also correctly aligned. –  Martin Scharrer Feb 1 '11 at 12:11
Martin: Where are the sublabels (a) and (c) not aligned? –  Herbert Feb 1 '11 at 12:16
In the OP, the two right tabulars share one sublabel, the \subfloat is outside both tabulars. I was assuming that is what the OP wants. The resulting (a) and (b) are not aligned in this case. –  Martin Scharrer Feb 1 '11 at 12:19

Use tabulars inside tabulars:

\documentclass{article}

\usepackage{subfig}

\begin{document}

\begin{table}
\centering
\subfloat[]{%
\begin{tabular}[b]{c}
\begin{tabular}[b]{cc}
\hline
0 & 1\\
\hline
2 & 1\\
3 & 1\\
4 & 2\\
5 & 3\\
4 & 8\\
\hline
\end{tabular}%
\end{tabular}%
}
\subfloat[]{%
\begin{tabular}[b]{c}%
\begin{tabular}{ccc}
\hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\
\hline
\end{tabular}
\\\\%
\begin{tabular}[b]{ccc}
\hline
1 & 2 & 3\\
3 & 7 & 4\\
4 & 5 & 4\\
\hline
\end{tabular}%
\\
\end{tabular}%
}%
\end{table}
\end{document}


Note, that the both parent and bottom tabular have a [b] argument. The left tabular must also be placed inside a parent tabular to get the same spacing to the subfloat label.

/edit: removed { } for inner tabulars.

Results:

Without left parent tabular:

With left parent tabular:

The added margins can be removed by replacing {c} with {@{}c@{}} in the parent tabulars.

-
@Martin Scharrer The solution is good, but I would recommend you change the \figure to table so any captions can refer to tables. –  Yiannis Lazarides Feb 1 '11 at 2:51
@Yiannis: Done, the OP used figure, so I first did not changed set. –  Martin Scharrer Feb 1 '11 at 8:16
@Martin: The left outer tabular is not needed and also not the {..} for the sub tabulars –  Herbert Feb 1 '11 at 12:10
@Herbert: You are definitive right about the {..}, I confused that with tabularx, where they are needed. –  Martin Scharrer Feb 1 '11 at 12:20
@Martin: no, tabularx also didn't braces around the body –  Herbert Feb 1 '11 at 12:26