[Tex/LaTex] longtable side by side

longtablepage-breakingtables

I've two longtables and I'd like to place them side by side. Tabular environments work very well, but I think it is not possible to place longtable side by side (why?).

It needs to be a longtable or a similar package because the table will be longer than a page. Here is an example of the two tables:

\documentclass{article}
\begin{document}
\begin{longtable}{|c|c|}
\caption{First Results} \\
\hline
28\% & 33\% \\
22\% & 36\% \\
58\% & 49\% \\
4\% & 89\% \\
\hline
\end{longtable}

\begin{longtable}{|c|c|}
\caption{Second Results} \\
\hline
24\% & 64\% \\
76\% & 22\% \\
2\% & 8\% \\
32\% & 55\% \\
\hline
\end{longtable}
\end{document}

Best Answer

Here is a minimally-disruptive solution using just longtable as suggested by Mike Renfro:

\documentclass{article}
\usepackage{longtable}
\begin{document}
  \begin{longtable}{c|c|c|cp{.3\linewidth}c|c|c|c}
    \multicolumn{4}{c}{Table \thetable\ First Results} & \multicolumn{1}{c}{\stepcounter{table}} & \multicolumn{4}{c}{Table \thetable\ Second Results} \\
    \cline{2-3}\cline{7-8}
    & 28\% & 33\% & & & & 24\% & 64\% \\
    & 22\% & 36\% & & & & 76\% & 22\% \\
    & 58\% & 49\% & & & & 2\% & 8\% \\
    & 4\% & 89\% & & & & 32\% & 55\%\\
    \cline{2-3}\cline{7-8}
  \end{longtable}
\end{document}

longtable solution

However, it may be better to follow the advice in the booktabs documentation and add a bit more spacing, dispensing with vertical rules:

\documentclass{article}
\usepackage{array,longtable,booktabs}
\begin{document}
  \begin{longtable}{cc>{\hspace*{.01\linewidth}}c<{\hspace*{.1\linewidth}}cc}
    \caption{Results}\\
    \toprule
    \multicolumn{2}{c}{First Results} & & \multicolumn{2}{c}{Second Results}\\\midrule\endhead
    \bottomrule\endfoot
     28\% & 33\% & & 24\% & 64\% \\
     22\% & 36\% & & 76\% & 22\% \\
     58\% & 49\% & & 2\% & 8\% \\
     4\% & 89\% & & 32\% & 55\%\\
 \end{longtable}
\end{document}

longtable and booktabs

But you might also think about how to set out the information. If everything is a % result, you might put this in the table caption and then present the first and second results as raw numbers. In this version, I also use the siunitx package to handle the numerical values nicely:

\documentclass{article}
\usepackage{array,longtable,booktabs,siunitx}
\begin{document}
  \begin{longtable}{SS>{\hspace*{.01\linewidth}}c<{\hspace*{.1\linewidth}}SS}
    \caption{Results (\%)}\\
    \toprule
    \multicolumn{2}{c}{First} & & \multicolumn{2}{c}{Second}\\\midrule\endhead
    \bottomrule\endfoot
     28 & 33 & & 24 & 64 \\
     22 & 36 & & 76 & 22 \\
     58 & 49 & & 2 & 8 \\
     4 & 89 & & 32 & 55\\
 \end{longtable}
\end{document}

siunitx, longtable and booktabs with rearranged content

Related Question