Large Tables in LaTeX – How to Create a Large Table Covering One or Several Double Pages?

columnspage-breakingtables

For the appendix of my Ph. D. thesis I need to typeset some very big tables containing raw data. They have about 30 columns and might have enough lines to not fit vertically on one (double)page.

Is there a package which allows to create a table which covers a whole double page (in width), so columns 1-15 on left page and columns 16-30 on right page and that even with one or more pagebreaks?

I know about longtable, but I didn't find an option which allows that.

The lines of both tables should be vertically aligned, however it might be a good idea to repeat the ("characteristic") first column also on the right page for clear identification of each line.

(Sure I could also split it up into more than one table but I would prefer to have all data for each measured part in one line.)

Further practical questions:

  • are there recommendations for such a case?

e.g.

  • would one caption on the first left page be enough?
  • normally I would make my tables with the booktabs package and avoid horizontal lines between "normal" table lines, however in this case it could be helpful to help the eye group the lines, maybe by groups of 3 (that would make sense for my data9 to help the eye follow the lines…
  • how can I reduce the outer margins (only) for those large tables to use most of the pagewidth?

Best Answer

I think that the only feasible option is to split the data into 2n parts:

  • first part, columns 1-15, rows 1-24, \newpage
  • second part, columns 16-30, rows 1-24, \newpage
  • third part, columns 1-15, rows 24-48, \newpage
  • fourth part, columns 16-30, rows 24-48, \newpage
  • ...

Twenty-four rows is just to put some number. If the data and the header row are homogeneous in height, they should align perfectly.

For the caption, it can go on the left page, but I suggest to set it into a \vbox with prescribed height:

\newcommand{\mycaption}[1]{\vbox to 3\baselineskip{
   \vfill\captionof{table}{#1}\vfill}}

where 3 is a number bigger than the number of lines in the caption. For the right page you can say

\newcommand{\fakecaption}{\vbox to 3\baselineskip{}}

and insert \fakecaption after the \newpage; \captionof requires the caption package.

The margins can be overridden either with \newgeometry of the geometry package or simply by inserting each "subtable" inside \makebox[\textwidth]{}.

A possible implementation

\documentclass[a4paper,twoside]{book}
\usepackage{caption}

\newlength{\leftcaptionht}
\newsavebox{\tablebox}
\newcommand{\lefttable}[1]{%
  \setbox\tablebox=\vbox{\medskip\captionof{table}{#1}}
  \setlength{\leftcaptionht}{\ht\tablebox}%
  \box\tablebox}

\newenvironment{doubletable}
  {\newpage\ifodd\value{page}\null\newpage\fi\centering}{\newpage}
\newenvironment{widetabular}
  {\begin{lrbox}{\tablebox}\begin{tabular}}
  {\end{tabular}\end{lrbox}\makebox[\textwidth]{\usebox{\tablebox}}}

\newcommand{\righttable}{\newpage\vbox to\leftcaptionht{}}

\begin{document}

text 

\begin{doubletable}
\lefttable{This is a caption}

\begin{widetabular}{ll}
a column long enough to go over  & a column long enough to arrive over the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}

\righttable

\begin{widetabular}{ll}
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}

\end{doubletable}

\begin{doubletable}

\lefttable{This is a caption that occupies more than one line and so has to wrap, so that we 
can show that the alignment is correct}

\begin{widetabular}{ll}
a column long enough to go over  & a column long enough to arrive over the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}

\righttable

\begin{widetabular}{ll}
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
a column & a column long enough to arrive near the right margin\\
\end{widetabular}

\end{doubletable}

\end{document}

If you want a caption on the right pages, it's sufficient to define \righttable differently:

\newcommand{\righttable}{\newpage\vbox to\leftcaptionht{\medskip
  \noindent(Table \thetable{} (continued)}}

(or something similar).

The suggestion is to add rows to the tables until they fit on the page and then start a new pair.

Related Question