[Tex/LaTex] How to make a long table split on even/odd pages

double-sidedlongtable

On an A5 document, I want to print a long table, split on several pages (using longtable I know) but I also need the 2 columns of that table to be on each side of the document:

  • left column on even pages, spanning several pages
  • right column on odd pages, spanning several pages

There is of course text before and after that table, or I wouldn't ask. Ideally, the table would be framed. And repeat the header of each columns (on it's page), but that should be easy with longtable.

This thing is to compare features of 2 different somethings, therefore I don't absolutely need perfectly aligned tables, the 2 columns can be itemized. And the repeated header could be replaced with repeated captions. But if so, the borders would become important.

I could imagine one 1 column table printed on even pages, and another 1 column table printe on odd pages, but they need to be "nested", facing each other in the A5 book.


Alternatively, if there is no solution to have a table span several pages laterally, is there a way to have text flow only on even pages, and some other text flow on odd pages, facing each other ? May-be defining 2 floats, one for even pages and one for odd pages, and each would overflow into the next even-or-odd page ?

The question could then be reframed like this: is it possible to have a float spanning several pages, but restricting it to only even (or odd) pages ?

I can make it by hand, with page-jumps, but if text is added, or the page-layout changed, it would screw all up (and this would defeat the whole LaTeX philosophy). I know that such things are possible with Scribus.

Best Answer

enter image description here

\documentclass[a5paper,twoside]{article}

\textheight.5\textheight
\paperheight.7\paperheight
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth

\usepackage{array,longtable,color}

\makeatletter

\def\LT@output{%
  \ifnum\outputpenalty <-\@Mi
    \ifnum\outputpenalty > -\LT@end@pen
      \LT@err{floats and marginpars not allowed in a longtable}\@ehc
    \else
      \setbox\z@\vbox{\unvbox\@cclv}%
      \ifdim \ht\LT@lastfoot>\ht\LT@foot
        \dimen@\pagegoal
        \advance\dimen@-\ht\LT@lastfoot
        \ifdim\dimen@<\ht\z@
    \setbox\zzz\vbox{\moveleft10in\vbox{\unvcopy\@cclv\copy\LT@foot}\vss}%
    \setbox\@cclv\vbox{\vbox{\unvbox\@cclv\copy\LT@foot}\vss}%
    \@makecol
    \@outputpage
     \setbox\@cclv\box\zzz
    \@makecol
    \@outputpage
          \setbox\z@\vbox{\box\LT@head}%
        \fi
      \fi
      \global\@colroom\@colht
      \global\vsize\@colht
%      \vbox
%      {\unvbox\z@\box\ifvoid\LT@lastfoot\LT@foot\else\LT@lastfoot\fi}%
    \fi
  \else
    \setbox\zzz\vbox{\moveleft10in\vbox{\unvcopy\@cclv\copy\LT@foot}\vss}%
    \setbox\@cclv\vbox{\vbox{\unvbox\@cclv\copy\LT@foot}\vss}%
    \@makecol
    \@outputpage
     \setbox\@cclv\box\zzz
    \@makecol
    \@outputpage
      \global\vsize\@colroom
    \copy\LT@head\nobreak
  \fi}

\newbox\zzz



\def\a{%
one&&red\\
two&&green\\
three&&yellow\\
four&&brown\\
}
\def\b{%
111&&this\\
2&&that\\
333&&the other\\
44&&something\\}

\begin{document}

\begin{titlepage} testing longtable\end{titlepage}
\pagenumbering{arabic}

\clearpage\ifodd\value{page}\mbox{}\clearpage\fi
\setlength\LTright{-3\textwidth plus 1fill}
\begin{longtable}{cp{10in}c}
LEFT&&RIGHT\\
\endhead
first&&row\\
\a\uppercase{\a}\b
\a\uppercase{\a}\b\b
last&&row\\
\pagebreak% you need this
\end{longtable}

\end{document}