Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two tables side by side in one column LaTeX environment

Tags:

layout

latex

The question is similar to this one: How to display a content in two-column layout in LaTeX? but about placing two tables side by side.

I have two small tables looking like that:

\begin{table}[t]
\begin{tabular}{|c|l||r|r||r|r|}
%content goes here
\end{tabular}
\caption{some caption} 
\end{table}

\begin{table}[t]
\begin{tabular}{|c|l||r|r||r|r|}
%content goes here
\end{tabular}
\caption{some caption for second table} 
\end{table}

I have one-column document and these tables are really narrow, so I would like to display them side by side (with separate captions) insted of one under another with a lot of unused, white space.

I tried to do it with this \multicols but it seems that floats (tables here) cannot be placed inside of it.

Any ideas?

EDIT
OK, I've done something like that:

\begin{table}[h]
\begin{minipage}[b]{80mm}
\begin{tabular}{|c|l||r|r||r|r|}
%//first table goes here
\end{tabular}
    \caption{some caption for first table} 
\end{minipage}

\begin{minipage}[b]{80mm}
\begin{tabular}{|c|l||r|r||r|r|}
%//second table goes here
\end{tabular}
    \caption{some caption for second table} 
\end{minipage}

 \end{table}

But the table is always using as much space, as it needs, no matter what size of minipage I would set. For example, if I have 80 mm for minipage, the caption will be limited to these 80 mm but the table will be wider.

If I have two tables, and one table is just a little bit too wide, it would not apper next to first table, but underneath.

Is there any way to limit the table to specified width? Or to force them to appear one next to another? Or maybe how to change the font size just for one of the tables?

like image 828
Gacek Avatar asked Jun 17 '10 14:06

Gacek


People also ask

Can you put two tables side by side in LaTeX?

In case the tables are to be set without table environment, there are two ways to put two tables side-by-side. First just put the two tables in a first one, second minipage. By using the first option \hline have to replaced by \cline.

How do I make different tables in LaTeX?

How do we create tables in LaTeX? The tables in LaTeX can be created using the table environment and the tabular environment which uses ampersands (&) as column separators and new line symbols (\\) as row separators.

How do I merge two tables in overleaf?

You can simply use the standard command multicolumn to achieve this. Then you choose which of the columns of the top tables should span more than one column of the lower table. Then do this in each row of the top table. it's versatile, you can easily use other columns and combine more than two tabulars.

How do you do multicolumn in LaTeX?

LaTeX Multiple Columns Text with two or double columns can be created by passing the parameter \twocolumn to the document class statement. If you want to create a document with more than two columns, use the package multicol, which has a set of commands for the same.


1 Answers

The reason your second table is going below the first table instead of right next to it is because of the space between the two minipages. You have to have the statements right below the other, otherwise latex would treat it like an end line. Took me about a week to figure this out for my own tables.

\end{minipage}
\begin{minipage}[b]{80mm}

Instead of:

\end{minipage}

\begin{minipage}[b]{80mm}
like image 57
Derek Avatar answered Sep 19 '22 23:09

Derek