# [texhax] making a long, narrow, 2-column table into a shorter, wider, 4-column table

Christopher W. Ryan cryan at binghamton.edu
Wed Sep 18 15:31:31 CEST 2013

I think my question sort of straddles two mailing lists, texhax and
r-help. I'll try texhax first.

I have a very long two-column table, short words down the left column
and their frequency in documents down the right column. The rows are
sorted by decreasing frequency. Typeset in the conventional way, this
puts the table centered, consuming two pages, but with wide swaths of
empty white space on either side.

Note that the LaTeX code is generated automatically by R, Sweave, and
the HMisc package.

\begin{table}\centering
\caption{very long but narrow table}
\begin{tabular}{l|l}
word1 & 7 \\
word2 & 5 \\
... lots of rows ...
last word & 1
\end{tabular}
\end{table}

I'd like to use the width of the page more efficiently, thereby fitting
the table all one one page, by making the table 4 columns (2 pairs of
columns), with the rows  "flowing" from the bottom of one pair to the
top of the next pair, adjacent to it.

I know I could modify the code for the table "by hand," after
R/Sweave/HMisc generates it, splitting it at some row roughly halfway
down, something like this:

\begin{table}\centering
\caption{very long but wider 4-column table}
\begin{tabular}{l|l|l|l}
word1 & 7          &      ... some more rows ... \\
word2 & 5          &      next-to-last word & 2 \\
... some rows ...  &      last word & 1
\end{tabular}
\end{table}

But is there a way to do this programmatically, without manual
post-processing of the LaTeX code that is generated by R/Sweave/HMisc?

Thanks.

--Chris
--
Christopher W. Ryan, MD, MS
SUNY Upstate Medical University Clinical Campus at Binghamton
425 Robinson Street, Binghamton, NY  13904
cryanatbinghamtondotedu

"Once we recognize that we do not err out of laziness, stupidity, or
evil intent, we can liberate ourselves from the impossible burden of
trying to be permanently right. We can take seriously the proposition
that we could be in error, without deeming ourselves idiotic or
unworthy." [Karen Schulz, in Being Wrong: Adventures in the Margin of Error]