In Latex, how to put two separate tables side by side on top of the paper?

user3361508 picture user3361508 · Feb 23, 2015 · Viewed 25.3k times · Source

In Latex, how do I put two separate tables (with separate captains) side by side on top of a paper?

Any helps are highly appreciated.

Answer

Jan Berges picture Jan Berges · Feb 23, 2015

One possibility is to align the table environment with [t] and split it using minipages, optionally separated by a flexible space.

\documentclass{article}

\def \hfillx {\hspace*{-\textwidth} \hfill}

\begin{document}
    \begin{table}[t]
        \begin{minipage}{0.5\textwidth}
            \centering
            \begin{tabular}{r | c c c}
                $+$
                  & 1 & 2 & 3 \\\hline
                1 & 2 & 3 & 4 \\
                2 & 3 & 4 & 5 \\
                3 & 4 & 5 & 6
            \end{tabular}
            \caption{Addition}
        \end{minipage}
        \hfillx
        \begin{minipage}{0.5\textwidth}
            \centering
            \begin{tabular}{r | c c c}
                $\times$
                  & 1 & 2 & 3 \\\hline
                1 & 1 & 2 & 3 \\
                2 & 2 & 4 & 6 \\
                3 & 3 & 6 & 9
            \end{tabular}
            \caption{Multiplication}
        \end{minipage}
    \end{table}
    %
    \section{Section}

    Text
\end{document}

If the tables are big, it may be necessary to enlarge the upper fraction of the page in which floats are allowed by putting this into the preamble:

\def \textfraction {0.1}
\def \topfraction {0.9}