Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?
share|improve this question
1  
I don't think that there is such a package, which can split the columns over two pages. I personally would write a small script (e.g. Perl) to auto-generate the code (two separate tabulars) from the data. If they don't fit on one page each you need to adjust the script to generate more pages. I know it's some effort. –  Martin Scharrer Jun 27 '11 at 8:48
1  
Indeed, AFAIK there isn't such a package. Personally, I'd write two separate documents for the table, and use pdfpages to include the table. –  Leo Liu Jun 27 '11 at 11:07
    
@Leu Liu: Thanks for your comment - that's what I did not, however the vertical adjustment on the right page (without caption) remains a problem (see my comment on egreg's answer). –  Martin Jul 1 '11 at 23:27
    
@Martin Scharrer: thanks, that's in general a good idea, but too difficult for a Puggle (=non-programming person) like me. ;-) I did it by hand in a nasty multi-step-process exporting the tables from my statistics software to MS Excel, rearranging them and then using the Excel2LaTeX-VBA-Plugin to export the LaTeX-Code which for sure had to be adjusted to work as expected.. [But if I had written any code to do that, it would have taken longer, I suppose, and - taking into account my programming skills - I could not be sure that any of the numbers is at the right place afterwards...] –  Martin Jul 1 '11 at 23:30
1  
See this answer here for a semi-automatic solution: Table and multi-page –  Alan Munn Jul 2 '11 at 16:26
show 1 more comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
Thanks for your suggestion! I decided to split the table and typeset it page by page in a second pdf document and then include the pages with \includegraphics. Your solution for the vertical alignment is interesting. Is there a way to directly determine the real height of the caption on the left side and use this value on the right side for a \vspace? For a caption with 2 lines, 3*baselineskip is nearly perfect, just a little bit too much. –  Martin Jul 1 '11 at 23:25
    
thank you for the additional example! That looks very promising - I'll try it out later. –  Martin Jul 2 '11 at 13:17
    
Thanks for your help! It works great, as long as the height of the table fits on the page. But it fails, if the height of the table is too big, then the caption for the left table is on the left page and the table itself lands on the right page.. Can you help me fix that? –  Martin Jul 2 '11 at 23:35
    
p.s. would it be possible to add in the placeholder for the caption on the right page something like "continuation of table on the left page" (I'm not sure how to say that in English correctly) –  Martin Jul 3 '11 at 0:52
add comment

you can create the table with ConTeXt, it can split tabulars also in the horizontal direction. The created pdf can then be inserted into your document if you need to run it with pdflatex

share|improve this answer
    
thanks, that's interesting. I knew nothing about ConTeXtand a first quick google search tells me that it might be too complicated to dive in just for some tables. But it is good to know that there seems to be a "built-in" a solution elsewhere. –  Martin Jul 2 '11 at 12:50
    
@Martin: I posted an example here, but didn't find the message –  Herbert Jul 2 '11 at 13:11
    
thanks to Alan Munn's comment above, I've not only found the dpfloatpackage which might help for aligning 2 tables on a double page, but there is also your example for ConTeXt : tex.stackexchange.com/questions/8959/table-and-multi-page/… –  Martin Jul 2 '11 at 19:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.