I started with my answer at How do I create 6 parallel texts aligned by paragraph, with 3 texts on each page? as a baseline, but had to make a number of changes.
On the easier side, I don't have to worry about row entries of different heights for this OP's query. But on the negative side, I had to significantly rewrite code to handle 10 or more column entries (since #10
doesn't work). To that end, I didn't pass different column entries as arguments, but wrote my own tab parsing code, so that the row could be entered as if it were a tabular row.
I still used Herbert's code snippet for processing tabular tokens within a \whiledo
, and I added a snippet from Stephan Lehmke for starting the table on an even page number when in twoside
mode.
As a bonus feature, not only do I allow the code to be broken across left/right pages, but it can be broken vertically as well, for extra long tables. The syntax is \newtwopagetable
to initialize the process. Then, individual rows are added with \tenbyrow{}
where the argument is a &
-separated list of ten entries (it is minor rewrite for other column number entries). Finally, when all the data is entered in this fashion, you have two options:
\newtwopagetable{caption}
will output the whole table over two pages; or
\maketwopagetable[4]{caption}
\maketwopagetable[4]{caption}
will split the two-sided table into vertical pieces, as well, shown above as four rows on the first double page, and four rows on the second double page.
Here is the source code:
\documentclass[twoside]{article}% TABLE CLEARS TO EVEN PAGE
%\documentclass{article}% TABLE CLEARS TO NEXT PAGE
\usepackage{booktabs, array}
\usepackage{ifthen}
\usepackage{etoolbox}
\makeatletter%%%%%%%%%%% My own tab parsing code
\newcounter{TABcellindex@}
\newcommand\readTABrow[2]{%
\def\doneTABread{F}%
\def\postTAB{#2}%
\setcounter{TABcellindex@}{0}%
\whiledo{\equal{\doneTABread}{F}}{%
\stepcounter{TABcellindex@}%
\expandafter\processTAB\postTAB&\\%
\ifthenelse{\equal{\preTAB}{}}{%
\addtocounter{TABcellindex@}{-1}%
\def\doneTABread{T}%
}{%
\expandafter\protected@edef\csname #1\alph{TABcellindex@}\endcsname{%
\preTAB}%
}%
}%
% \#1TABcells GIVES HOW MANY TAB COLUMNS WERE PROCESSED
% \expandafter\xdef\csname #1TABcells\endcsname{\arabic{TABcellindex@}}%
}
\def\processTAB#1\\{%
\protected@edef\preTAB{#1}%
\protected@edef\postTAB{#2}%
}
\makeatother%%%%%%%%%%% END My own tab parsing code
\makeatletter%%%%%%%%%%% Herbert's tabular token code
\newcounter{tabindex}
\newtoks\@tabtoks
\newcommand\addtabtoks[1]{%
\@tabtoks\expandafter{\the\@tabtoks\stepcounter{tabindex}#1}}
\newcommand*\resettabtoks{\@tabtoks{}}
\newcommand*\synctabindex[1]{\setcounter{tabindex}{\value{#1}}}
\newcommand*\printtabtoks{\the\@tabtoks}
\makeatother%%%%%%%%%%% END Herbert's tabular token code
\makeatletter%%%%%%% Lehmke's \cleartoleftpage
\def\cleartoleftpage{\clearpage\if@twoside \ifodd\c@page
\hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\makeatother%%%%%%%% END Lehmke's \cleartoleftpage
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcounter{sptstartrow}
\newcounter{sptendrow}
\newcounter{entries}
\newcommand\newtwopagetable{%
\setcounter{sptendrow}{0}%
\setcounter{entries}{0}%
\cleartoleftpage%
}
\makeatletter
\newcommand\tenbyrow[1]{%
\stepcounter{entries}%
\readTABrow{entryX\roman{entries}X}{#1}%
}
\makeatother
\newcounter{index}
\newcommand\maketwopagetable[2][\theentries]{%
\setcounter{sptstartrow}{\thesptendrow}%
\ifthenelse{\thesptstartrow > 1}%
{\addtocounter{table}{-1}\def\conttext{, continued}}%
{\def\conttext{}}%
\addtocounter{sptendrow}{#1}%
\ifthenelse{\thesptendrow > \theentries}{\setcounter{sptendrow}{\theentries}}{}%
\clearpage
\setcounter{index}{\thesptstartrow}%
\synctabindex{index}
\resettabtoks%
\whiledo{\theindex < \thesptendrow}{%
\stepcounter{index}%
\addtabtoks{%
\csname entryX\roman{tabindex}Xa\endcsname &
\csname entryX\roman{tabindex}Xb\endcsname &
\csname entryX\roman{tabindex}Xc\endcsname &
\csname entryX\roman{tabindex}Xd\endcsname &
\csname entryX\roman{tabindex}Xe\endcsname
\\%
}%
}%
\begin{table}
\centering
\begin{tabular}{C{2cm} C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule
\printtabtoks%
\bottomrule
\end{tabular}%
\caption{#2 (left half\conttext)}
\end{table}%
\addtocounter{table}{-1}%
\clearpage
\setcounter{index}{\thesptstartrow}%
\synctabindex{index}
\resettabtoks%
\whiledo{\theindex < \thesptendrow}{%
\stepcounter{index}%
\addtabtoks{%
\csname entryX\roman{tabindex}Xf\endcsname &
\csname entryX\roman{tabindex}Xg\endcsname &
\csname entryX\roman{tabindex}Xh\endcsname &
\csname entryX\roman{tabindex}Xi\endcsname &
\csname entryX\roman{tabindex}Xj\endcsname
\\%
}%
}%
\begin{table}
\centering
\begin{tabular}{C{2cm} C{2cm} C{2cm} C{2cm} C{2cm}}
\toprule
\printtabtoks%
\bottomrule
\end{tabular}%
\caption{#2 (right half\conttext)}
\end{table}%
}
\begin{document}
\newtwopagetable
\tenbyrow%
{~ & \textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} &
\textbf{Column 4} & \textbf{Column 5} & \textbf{Column 6} &
\textbf{Column 7} & \textbf{Column 8} & \textbf{Column 9}}
\tenbyrow%
{\textbf{Row 1} & Text (1,1) & Text (1,2) & Text (1,3) & Text (1,4)
& Text (1,5) & Text (1,6) & Text (1,7) & Text (1,8) & Text (1,9)}
\tenbyrow%
{\textbf{Row 2} & Text (2,1) & Text (2,2) & Text (2,3) & Text (2,4)
& Text (2,5) & Text (2,6) & Text (2,7) & Text (2,8) & Text (2,9)}
\tenbyrow%
{\textbf{Row 3} & Text (3,1) & Text (3,2) & Text (3,3) & Text (3,4)
& Text (3,5) & Text (3,6) & Text (3,7) & Text (3,8) & Text (3,9)}
\tenbyrow%
{\textbf{Row 4} & Text (4,1) & Text (4,2) & Text (4,3) & Text (4,4)
& Text (4,5) & Text (4,6) & Text (4,7) & Text (4,8) & Text (4,9)}
\tenbyrow%
{\textbf{Row 5} & Text (5,1) & Text (5,2) & Text (5,3) & Text (5,4)
& Text (5,5) & Text (5,6) & Text (5,7) & Text (5,8) & Text (5,9)}
\tenbyrow%
{\textbf{Row 6} & Text (6,1) & Text (6,2) & Text (6,3) & Text (6,4)
& Text (6,5) & Text (6,6) & Text (6,7) & Text (6,8) & Text (6,9)}
\tenbyrow%
{\textbf{Row 7} & Text (7,1) & Text (7,2) & Text (7,3) & Text (7,4)
& Text (7,5) & Text (7,6) & Text (7,7) & Text (7,8) & Text (7,9)}
\maketwopagetable{This is a table}
\newtwopagetable
\setcounter{entries}{8}% THIS IS TO FOOL LaTeX INTO THINKING I RE-ENTERED THE TABLE DATA
\maketwopagetable[4]{This is a vertically split table}
\maketwopagetable[4]{This is a vertically split table}
\end{document}
Here is the full table output on a double page:

While here is the table, split width and lengthwise, as output over the next four pages. Note that the (left/right half, continued)
commentary is provided by \maketwopagetable
, and is not part of the user's captioning argument.




table
isn't trivial though...