2

I am a complete newbie at LaTeX and I would like to reproduce the following (exemplary) layout: enter image description here

The key requirements are:

  1. The table must span multiple pages vertically;
  2. The table must be split on even/odd pages in landscape layout, so that each other page would continue the table horizontally, and each pair of pages would continue the table vertically;
  3. The headers must be repeated.

I am aware of multiple packages that deal with tables (longtable, tabularx, ltablex), but I am having difficulties even choosing the environment, let alone make that layout happen using the documentation.

Edit: The actual data looks like this – column A is the width of the longest element, and there are several more columns to come: enter image description here

8
  • 1
    Paracol can handle the left-right splitting, but will not necessarily align the two halves. What you might do is create the table in a separate document with a wider text area and copy/split the resulting PDF. Jan 13 at 15:24
  • @JohnKormylo sounds interesting, but I am not sure I understand the last part. What do you mean by “wider text area”? Jan 13 at 15:43
  • If the screenshot shows a table with contents similar to your planned table, you could probably even be able to squeeze all columns onto one page, in which case a regular longtable would work perfectly fine. This however depends largely on the table's contents as well as on the length of the column headers and the first column.
    – leandriis
    Jan 13 at 18:50
  • @leandriis unfortunately I tried, but there is no way to make it work with any reasonable layout. I did consider manually splitting the data and generating separate tables, but wanted to keep it in LaTeX. Jan 13 at 18:57
  • 1
    Use geometry to create a document with no margins and set \paperwidth to twice you current \textwidth and \paperheight to the current \textheight (print \the\textwidth and \the\textheight to find out). Jan 14 at 14:02
1
+50

Based on John Kormylo's suggestion of creating the table in a separate document of appropriate size and later on including it in the main document, here is a first rough approach:

The following MWE is used to create the table. The values for paperheight and paperwidth are equal to textheight and 2*textwidth, respectively, of the document, in which you want to add the table (You can use \the\textheight and \the\textwidth to get the corresponding values.)

\documentclass{article}
\usepackage[margin=0pt, paperheight=556.47656pt, paperwidth=860.00924pt]{geometry}

\usepackage[table]{xcolor}
\usepackage{xltabular}
\usepackage{makecell,rotating}

\usepackage{pifont}
\newcommand{\cm}{\cellcolor{green!50!white}\ding{51}}%
\newcommand{\xm}{\cellcolor{red!50!white}\ding{55}}%

\begin{document}
\small
\setlength{\tabcolsep}{3pt}
\settowidth\rotheadsize{\theadfont other text}
\begin{xltabular}{\textwidth}{r*{50}{c}}
           & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{more text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{other text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} & \rothead{text} \\\endhead
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
word 
  & \cm & \cm & \xm & \xm & \cm & \xm & \xm & \cm & \cm & \cm 
  & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \xm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \xm & \cm  \\
short text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \cm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \cm & \cm & \cm & \xm & \cm & \xm  \\
a bit longer text 
  & \cm & \cm & \xm & \cm & \cm & \cm & \xm & \cm & \cm & \cm 
  & \xm & \cm & \cm & \cm & \xm & \xm & \cm & \cm & \cm & \xm 
  & \cm & \xm & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \xm 
  & \xm & \xm & \xm & \cm & \xm & \cm & \cm & \cm & \cm & \cm 
  & \cm & \xm & \cm & \cm & \xm & \cm & \cm & \cm & \cm & \cm  \\
\end{xltabular}

\end{document}

This is how the resulting pdf file (named mylongtable.pdf in this particular case) looks like:

enter image description here

To automatically include the table into the actual document, I have written the macro \includemytable which automatically crops the right half of the image and inserts the remaining left half, then crops the left half and inserts the remaining right half. With the help of Heiko Oberdiek's answer, the macro iterates over all pages present in the file mylongtable.pdf. You can adjust the file name using \renewcommand{\mytablename}{<your file name here>}. To make sure, the table starts on a left (even) page, I used \cleartoleftpage originally defined by Martin Scharrer.

This is the resulting MWE:

\documentclass{article}

\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum}

\newcommand*\cleartoleftpage{%
  \clearpage
  \ifodd\value{page}\hbox{}\newpage\fi
} % from: https://tex.stackexchange.com/a/11709/134144

\usepackage{pgffor}
\newcounter{pdfpages}
\newcommand*{\getpdfpages}[1]{%
  \begingroup
    \sbox0{% 
      \includegraphics{#1}%
      \setcounter{pdfpages}{\pdflastximagepages}%
    }%
  \endgroup
} % from: https://tex.stackexchange.com/a/125212/134144


\newcommand{\mytablename}{}

\renewcommand{\mytablename}{mylongtable}
\newcommand{\includemytable}{%
                                \getpdfpages{\mytablename.pdf}
                                \foreach \x in {1,...,\value{pdfpages}} {
                                \noindent%
                                \includegraphics[trim=0pt 0pt \the\textwidth pt 0pt, clip,  page=\x]{\mytablename}%
                                \par%
                                \noindent%
                                \includegraphics[trim=\the\textwidth pt 0pt 0pt 0pt, clip, page=\x]{\mytablename}%
                                \par}}
                                
\begin{document}

\lipsum
\lipsum[1-5]

\cleartoleftpage
\includemytable
\lipsum   
\end{document}

and its output:

enter image description here


Warning: With the current approach, the table is cut right in the middle. Depending on the column widths it can thus happen that the table is cut in the middle of a column. To overcome this, one would have to adjust the column widths to make sure the middle of the table is exactly between two adjacent columns. I did not (yet) address this issue in my answer!

12
  • 1
    to avoid problems with the cutting add some space between two columns with @{\hspace{1cm}}. (And yes, one has to do some careful calculations of the column widths in such a setup). Jan 16 at 14:52
  • @UlrikeFischer could you explain a bit more where that should be defined? Within the macro itself? Jan 16 at 21:47
  • 1
    Heiko Oberdiek mentions in his anwer from which I took the code to iterate over all pages of the pdf file, that \pdflastximagepages in only available when using PDFLaTeX. For XeLaTeX, Are there macros that behave like \pdfximage and \pdflastximagepages but can be compiled with XeLaTeX? might be interesting.
    – leandriis
    Jan 17 at 17:39
  • 1
    To make the code compilable with XeLaTeX, replace \getpdfpages{\mytablename.pdf} with \edef\numberofpages{\the\XeTeXpdfpagecount \mytablename.pdf } and \foreach \x in {1,...,\value{pdfpages}} { with \foreach \x in {1,...,\numberofpages} {\numberofpages.
    – leandriis
    Jan 17 at 17:41
  • 1
    Adding \renewcommand\tabularxcolumn[1]{m{#1}} to the preamble in combination with \begin{xltabular}{\textwidth}{>{\raggedleft\arraybackslash}X*{50}{c}} should help in order to vertically center the contents of each row.
    – leandriis
    Jan 18 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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