# longtable: Rearrange per-page data in columns, then rows

I have a long table in a document which lists about 300 items. The table is actually generated by an external shell script in a format that is compatible with the longtable package. The script is my own, so I can modify it if needed.

I would like to use two columns to list the items in the table. If I just go through all the items in order, the table will look like this:

| Item1   | Item2   |
| Item3   | Item4   |
| Item5   | Item6   |
[...]
| Item299 | Item300 |


However I would like to arrange data so that consecutive items are in the same column (not in the same row). As an example, let's assume each page can hold 20 rows. Within each page I would like to have:

(page 1)
| Item1   | Item21  |
| Item2   | Item22  |
| Item3   | Item23  |
[...]
| Item20  | Item40  |

(page 2)
| Item41  | Item61  |
| Item42  | Item62  |
[...]


And so on.

I cannot just modify the shell script to generate the data in a different order because the shell script has no way to know how many rows would fit in a page.

Is there any package that would automatically take care of this?

• is that really a table, or just a list of items (which would easily be wrapped in the specified order eg using multicol) – David Carlisle Nov 7 '16 at 12:51
• It is a table containing three cells per item: A numeric index, a symbol, and a description of the symbol. – Grodriguez Nov 7 '16 at 15:07
• but why not just set that as a list of paragraphs with suitable styling, in what sense does it need to be a table if the horizontal association is arbitrary depending on page size? (you description sounds much more like a \begin{description} list (with a two-part label consisting of number and symbol) than it does a table. Lists naturally flow in the order you need. – David Carlisle Nov 7 '16 at 15:16
• You are right, it does not actually need to be a table (just needs to look like one). The only place where horizontal association matters is that I am currently alternating row colors. If this is a two-column list and not a table, then there's no concept of "row" anymore. Would I still be able to achieve a similar effect? – Grodriguez Nov 7 '16 at 16:49
• the purpose of zebra stripes in a table is normally to aid the reader to read across the table, seems like you want to discourage that here... But if you force each entry to be the same height (eg put it in a fixed height parbox) then you could put alternate background colours in place. – David Carlisle Nov 7 '16 at 16:53