3

I'm constructing a longtable with paired data sets that spans several pages. However, once I reach the end of the first column on page 1, the data continue into the first column of page 2. Is there any way to cycle the columns so that the data continue into the second column of page 1, instead?

In the example below, 17 and Q move to page 2; is there any way to automatically have this cycle into the right half of the table on page 1? I'd rather not automatically enter it that way in case I need to change page layouts later on.

MWE:

\documentclass[12pt]{report}
\usepackage{longtable}

\begin{document}
\huge
\begin{longtable}{cc|cc}

\hline \multicolumn{1}{c}{A} & \multicolumn{1}{c}{B} & \multicolumn{1}{c}{C} & \multicolumn{1}{c}{D} \\ \hline
\endfirsthead

\multicolumn{4}{c}
{Continued} \\
\hline \hline \multicolumn{1}{c}{A} & \multicolumn{1}{c}{B} & \multicolumn{1}{c}{C} & \multicolumn{1}{c}{D} \\ \hline
\endhead

\hline
\multicolumn{4}{r}{{Next page}} \\ 
\endfoot

1 & A & & \\
2 & B & & \\
3 & C & & \\
4 & D & & \\
5 & E & & \\
6 & F & & \\
7 & G & & \\
8 & H & & \\
9 & I & & \\
10 & J & & \\
11 & K & & \\
12 & L & & \\
13 & M & & \\
14 & N & & \\
15 & O & & \\
16 & P & & \\
17 & Q & & \\
18 & R & & \\
19 & S & & \\
20 & T & & \\
21 & U & & \\
22 & V & & \\

\end{longtable}
\end{document}
4
  • Are you sure that a table is right for this? Maybe you want multiple columns instead? (I'm not sure because I'm not clear what 'paired data sets' means or what that needs in terms of format.)
    – cfr
    Apr 24, 2015 at 0:02
  • I'd rather not so that I can keep formatting consistent with other single page tables throughout the document, but I'll have to go that route if no other solutions arise.
    – Richard
    Apr 24, 2015 at 0:05
  • You can't make longtable automatically flow stuff from one column to another. It just isn't designed to do that. At least, no reasonably straightforward way. It is outputting row-by-row, as far as I know, so it cannot go back and put stuff from a later row into an earlier one.
    – cfr
    Apr 24, 2015 at 0:10
  • 1
    By the way, if you'd like your tables to look good, take a look at booktabs.
    – cfr
    Apr 24, 2015 at 0:11

1 Answer 1

3

As mentioned in the comments, a tabular construct is not designed to allow text to flow from one column to another. Tables have a fixed number of columns and the text is in one of those columns. Thus you will need to rethink either your input format (a multicolumn approach rather than a tabular one) or your output expectations.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .