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.

Suppose I have two tables that don't have many columns (3, for example). How can I position them side by side?

share|improve this question
2  
This question is quite popular, but the answers seem to have quite some overlap, but lack a coherent comparsion of the pros & cons of the different techniques used: minipage, subfig & subfloat, \quad (?), parbox, subcaption & subtable. Is there a consensus of what's considered best, if both "subtables" also have some basic (not a fully-fledged one with the "Table 2.1"-bit) caption? –  nutty about natty Apr 18 '13 at 5:59
add comment

4 Answers

Just put two tabular environments side by side. Add spacing as desired.

\begin{tabular}{ccc}
\hline
a&b&c\\
\hline
\end{tabular}
\quad
\begin{tabular}{ccc}
\hline
d&e&f\\
\hline
\end{tabular}

If you want to use subfig because you want them to have separate captions, then that is simple as well.

\subfloat[caption]{\begin{tabular}{...}...\end{tabular}}
\subfloat[caption]{\begin{tabular}{...}...\end{tabular}}

If you want two tables that are independent, and thus don't want to use \subfloat, you can use \parbox.

\begin{table}
\parbox{.45\linewidth}{
\centering
\begin{tabular}{ccc}
\hline
a&b&c\\
\hline
\end{tabular}
\caption{Foo}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{ccc}
\hline
d&e&f\\
\hline
\end{tabular}
\caption{Bar}
}
\end{table}

This is basically the same as before just that I've centered each tabular in a \parbox with an included caption and wrapped the whole thing in a table.

share|improve this answer
add comment

Ceteris paribus, you might consider the subfig package. It is suitable for subtables and subfigures and combinations of these. For myself, I've managed much mileage from it.

share|improve this answer
add comment

If you want two tabulars next to each other in a (floating) table environment, then you can use minipages

screenshot

\begin{table}[!htb]
    \caption{Global caption}
    \begin{minipage}{.5\linewidth}
      \caption{}
      \centering
        \begin{tabular}{ll}
            1 & 2
        \end{tabular}
    \end{minipage}%
    \begin{minipage}{.5\linewidth}
      \centering
        \caption{}
        \begin{tabular}{ll}
            3 & 4
        \end{tabular}
    \end{minipage} 
\end{table}

Loading the caption package will allow easy customization, and will remove the : when the caption is empty.

If you'd like 'sub'tables, then you can use the subcaption package which introduces the subtable environment (and a lot more); the subtable environment takes the same mandatory and optional arguments as the minipage

screenshot

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

\begin{table}[!htb]
    \caption{Global caption}
    \begin{subtable}{.5\linewidth}
      \centering
        \caption{}
        \begin{tabular}{ll}
            1 & 2
        \end{tabular}
    \end{subtable}%
    \begin{subtable}{.5\linewidth}
      \centering
        \caption{}
        \begin{tabular}{ll}
            3 & 4
        \end{tabular}
    \end{subtable} 
\end{table}

\end{document}

Note that in both cases I've used a % at the end of the environment to stop overfull hboxes from the additional space added by the minipage.

share|improve this answer
    
Why would I want subtables vs tabulars? Of the two methods you describe in your answer, which is better (and why) ? –  nutty about natty Apr 18 '13 at 6:51
    
On a second glance: is the main (visible) difference between the two methods the way the "sub"-captions look (e.g., "Table 2" vs. "(a)") ? –  nutty about natty Apr 18 '13 at 6:57
1  
@nuttyaboutnatty yes, your second comment is accurate. It depends how you want the captions (and references) to look. It's up to you which you think is better :) –  cmhughes Apr 18 '13 at 17:00
    
Is there a way to have the tables start at the same height if they are of different lengths? –  Peter M Aug 25 '13 at 13:15
    
@PeterM you could use savebox- see my answer to Reasons for saving a box? –  cmhughes Aug 25 '13 at 15:36
add comment

I don't know that this is the best way, but you could make a 2-column table with a single row. In each cell of the table, wrap one of your intended tables in a minipage environment. Thus:

\documentclass{article}

\begin{document}

\begin{tabular}{cc}
    \begin{minipage}{.5\linewidth}
        \begin{tabular}{ll}
            1 & 2
        \end{tabular}
    \end{minipage} &

    \begin{minipage}{.5\linewidth}
        \begin{tabular}{ll}
            3 & 4
        \end{tabular}
    \end{minipage} 
\end{tabular}

\end{document}
share|improve this answer
10  
I'd appreciate a comment with the down vote; I might then learn something about what makes this a bad solution. –  vanden Sep 7 '10 at 4:23
1  
Sticking it in a minipage makes no sense to me at all. –  TH. Sep 7 '10 at 5:01
1  
Does this not work? My first guess was to solve it in this way... so how come it got a downvote? –  Johan Sep 7 '10 at 5:03
7  
I don't know why it got a downvote, but for my eyes the code has some faults: It gives an overful hbox message as the \parindent is not taken into account. It doesn't do what it probably wants to do: the tabular are not centered in the line as they are left aligned in the minipages. Also a minipage + an external tabular looks like an overkill (one at least could certainly be dropped) and makes the code difficult to read and changed. –  Ulrike Fischer Sep 7 '10 at 10:19
2  
@Ulrike: Thanks; that's very helpful. –  vanden Sep 7 '10 at 17:03
show 4 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.