Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

Table layout

\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}%
  }  \qquad
  \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.

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

A solution for both variants, two and three subfloats enter image description here

\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}}%
 \quad
 \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}}%
 \quad
 \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}
share|improve this answer
    
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
show 3 more comments

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}%
  }
  \quad
  \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:

no parent tabular

With left parent tabular:

parent tabular

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

share|improve this answer
    
@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
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.