Suppose I have two tables that don't have many columns (3, for example). How can I position them side by side?
7 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}}
\quad
\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.
-
3+1 to the the first option that is very simple and suited very well for me. – srodriguex May 13 '15 at 01:38
-
By the first option,
just put two tabular environments side by side, they aren't positioned next to each other, if I'm correct? – Mussé Redi Feb 24 '17 at 22:33 -
1
-
As @MusséRedi mentioned first solution does not work (at least for me). Solution using table and parbox worked fine. – Dimitrios Panagopoulos Apr 17 '22 at 04:37
If you want two tabulars next to each other in a (floating) table environment, then you can use minipages

\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

\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.
- 100,947
-
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 06:51
-
1On 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 06:57
-
2@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
-
2Is there a way to have the tables start at the same height if they are of different lengths? – petermeissner 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 -
Perfect. Just for clarification, I preferred to delete % since it looked awkward to have two conjoined table. – lonesome Jul 20 '17 at 05:32
-
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}
- 30,891
- 23
- 67
- 87
-
23I'd appreciate a comment with the down vote; I might then learn something about what makes this a bad solution. – vanden Sep 07 '10 at 04:23
-
Er, it wasn't me. Fyi, your solution's more or less the same as the one set out in the
subfigdocumentation section "Do You Need This Package?" So, except for the bells and whistles (e.g., decenttochandling), it's probably not too bad. – Geoffrey Jones Sep 07 '10 at 04:42 -
@Geoffrey: I did not assume it was you, nor does my comment suggest that I did so assume. (By the same token, yours doesn't suggest that you thought I did.) Thanks for the added info from the subfig docs. – vanden Sep 07 '10 at 04:45
-
He-he. Didn't think you did, just wanted an excuse so I could comment that your solution wasn't really all that bad :) – Geoffrey Jones Sep 07 '10 at 04:49
-
1
-
1Does this not work? My first guess was to solve it in this way... so how come it got a downvote? – Johan Sep 07 '10 at 05:03
-
9I 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 07 '10 at 10:19
-
@TH.: sticking single
tabulars in aminipageis indeed not very useful. However, if you also have\captions then this is IMHO the way to go, if both tables are separate and not sub-tables. I preferminipages before the very similar\parboxes because the first can e.g. contain verbatim material. – Martin Scharrer Jul 03 '11 at 21:42 -
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.
- 14,435
As the solution for tables (not subtables) side by side with the floatrow package is not mentioned here, I'll add it under the form of an answer to this duplicate question.
You can do that easily with the
floatrowpackage. I took the opportunity to propose another layout, without vertical rules, withbooktabs. For your original layout I added some vertical padding to the rows, with themakecellpackage.
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier, erewhon}
\usepackage{geometry}
\usepackage{array, caption, floatrow, tabularx, makecell, booktabs}%
\captionsetup{labelfont = sc}
\setcellgapes{3pt}
\begin{document}
\begin{table}[!htb]
\floatsetup{floatrowsep=qquad, captionskip=4pt}
\begin{floatrow}[2]
\makegapedcells
\ttabbox%
{\begin{tabularx}{0.45\textwidth}{|c| *{2}{>{\centering\arraybackslash}X|}}
\hline
& Sensibilità [$\%$] & Specificità [$\%$] \\
\hline
$ϵ'$ & 53.492 & 77.906 \\ \hline
$ϵ''$ & 46.753 & 61.587\\
\hline
\end{tabularx}}
{\caption[Valori medi]{valori medi}
\label{val1}}
\hfill%
\ttabbox%
{\begin{tabularx}{0.45\textwidth}{|c| *{2}{>{\centering\arraybackslash}X|}}
\hline
& Sensibilità [$\%$] & Specificità [$\%$]\\
\hline
$ϵ'$ & 60\hphantom{.000} & 80.487 \\ \hline
$ϵ''$ & 54.545 & 67.777\\
\hline
\end{tabularx}}
{\caption[Valori medi]{valori medi}
\label{val2}}
\end{floatrow}
\vspace*{1cm}
\begin{floatrow}[2]
\ttabbox%
{\begin{tabularx}{0.45\textwidth}{c *{2}{>{\centering\arraybackslash}X}}
\toprule
& Sensibilità [$\%$] & Specificità [$\%$] \\
\cmidrule(lr){2-2}\cmidrule(lr){3-3}
$ϵ'$ & 53.492 & 77.906 \\
\addlinespace
$ϵ''$ & 46.753 & 61.587\\
\bottomrule
\end{tabularx}}
{\caption[Valori medi]{valori medi}
\label{val1a}}
\hfill%
\ttabbox%
{\begin{tabularx}{0.45\textwidth}{c*{2}{>{\centering\arraybackslash}X}}
\toprule
& Sensibilità [$\%$] & Specificità [$\%$]\\
\cmidrule(lr){2-2}\cmidrule(lr){3-3}
$ϵ'$ & 60\hphantom{.000} & 80.487 \\
\addlinespace
$ϵ''$ & 54.545 & 67.777\\
\bottomrule
\end{tabularx}}
{\caption[Valori medi]{valori medi}
\label{val2a}}
\end{floatrow}
\end{table}%
\end{document}
2 tables side by side, with (or without) caption, without new packages: Just imbricate 2 tables! It is perfectly fine to have a table as a "regular" entry of another table
The top level table has 2 columns and 2 rows. The top row is the caption, the bottom row contains the "real" tables that you want.
See how \\ and & are used after \end{tabular}
\begin{tabular}{ cc } % top level tables, with 2 columns
caption 1 & caption 2 \\
% leftmost table of the top level table
\begin{tabular}{ |c|c|c| }
\hline
a & b & c \\
a & b & c \\
\hline
\end{tabular} & % starting rightmost sub table
% table 2
\begin{tabular}{ |c|c|c| }
\hline
d & e & f \\
d & e & f \\
\hline
\end{tabular} \\
\end{tabular}
- 199
I will add another answer to this question because I think this solution is more simple, for simple usages like putting two table side by side.
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[latin1]{inputenc}
\title{Table side by side}
\author{Vincenzo Palazzo}
\date{02/04/2023}
\begin{document}
\begin{table}[!htb]
\caption{Input and output transaction struct of Bitcoin Code.}
\begin{center}
\subtable{
\begin{tabular}{|c|c|}
\hline
\multicolumn{2}{|c|}{\textbf{TransactionInput}} \
\hline \hline
\multicolumn{1}{|c|}{Type} & \multicolumn{1}{c|}{Name} \
\hline
Outpoint & outpoint \
\hline
CScript & scriptSig \
\hline
$uint32_t$ & nSequence \
\hline
\end{tabular}
\centering
}
\subtable{
\centering
\begin{tabular}{|c|c|}
\hline
\multicolumn{2}{|c|}{\textbf{Outpoint}} \
\hline \hline
\multicolumn{1}{|c|}{Type} & \multicolumn{1}{c|}{Name} \
\hline
$uint256$ & hash \
\hline
$uint32_t$ & index \
\hline
\end{tabular}
}
\end{center}
\label{tab:tx_in_and_out}
\end{table}
\end{document}
- 267


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 05:59