Graphics, Figures & TablesHowto put long narrow tables into multiple columns

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
simon
Posts: 2
Joined: Sat Aug 01, 2009 8:39 pm

Howto put long narrow tables into multiple columns

Post by simon »

Consider the following table of three columns.

\begin{tabular}{ccc}
Ind & Number & Topic \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
2 & 2 & 2 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
3 & 3 & 3 \\
...etc...
10 & 10 & 10 \\
\end{tabular}

This is a long narrow table, so firstly we need to use the xtab package to break across multiple pages. However, each page then is very empty... it would be nice to place into columns and automatically balance them.
What I would to do is something like the following code:

\begin{multicols}{3}
\tablehead{Ind & Number & Topic \\}
\begin{xtabular}{ccc}
..entries as above..
\end{xtabular}
\end{multicols}

... but this doesn't work, everything is in just one column.

Using the \twocolumn option with xtab alone works, but I'd like three columns.
Obviously, I could manually typeset the table into three columns - balancing them manually... but it's then a nightmare to add new rows.

Any thoughts?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Howto put long narrow tables into multiple columns

Post by localghost »

At first, please use the code environment from the button list right above the input window to tag longer pieces of source code.

I suggest just to split the table into three parts. You can use three separate tabular environments or a single one with separated columns.

Code: Select all

\begin{table}[!ht]
  \caption{A narrow table split into three parts}\label{tab:threeparts}
  \centering
  \begin{tabular}{ccc}
    Ind & Number & Topic \\ \hline
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
    1 & 1 & 1 \\
  \end{tabular}
  \hspace{1em}
  \begin{tabular}{ccc}
    Ind & Number & Topic \\ \hline
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
    2 & 2 & 2 \\
  \end{tabular}
  \hspace{1em}
  \begin{tabular}{ccc}
    Ind & Number & Topic \\ \hline
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
    3 & 3 & 3 \\
  \end{tabular}
\end{table}

\begin{table}[!ht]
  \caption{A table consisting of three tables}\label{tab:threetables}
  \centering
  \begin{tabular}{ccc@{\qquad}ccc@{\qquad}ccc}
    Ind & Number & Topic & Ind & Number & Topic & Ind & Number & Topic\\ \hline
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
    1 & 1 & 1 & 2 & 2 & 2 & 3 & 3 & 3 \\
  \end{tabular}
\end{table}

Best regards and welcome to the board
Thorsten
simon
Posts: 2
Joined: Sat Aug 01, 2009 8:39 pm

Re: Howto put long narrow tables into multiple columns

Post by simon »

Oh yeah... didn't notice the code tags. Opps.

Manually breaking it into separate tabulars is a good solution... but it's not the best.

I'm not familiar enough with the code of multicols to work out how to get it to work with supertabular - was hoping someone here might know.

Thanks for the reply.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Howto put long narrow tables into multiple columns

Post by localghost »

simon wrote:[...] Manually breaking it into separate tabulars is a good solution... but it's not the best. [...]
It stays the best until there is a better one. If you make a find, post your solution here.
Post Reply