Skip to content

Instantly share code, notes, and snippets.

Created Mar 3, 2019
What would you like to do?
LaTeX multi-page table with inter-row page breaks
% First version published on
% Several changes are applied
\cals@ifbreak\iftrue % detect that a break is required
\splitHeight=\pagegoal \advance\splitHeight -\pagetotal
\ifdim \splitHeight>50pt % break inrow only if at least 100pt left
\advance\splitHeight -5pt % avoid pagebreak due to overflows
% Split the current row on two: before and after the break
\global\setbox\rowAfter=\box\rowAfter }%
\setbox2=\vsplit0 to\splitHeight
\setbox0=\vbox{\hbox to \wd2{}}%
\setbox\rowBefore=\hbox{\box2 \unhbox\rowBefore
\hbox to 0pt{\hss\vbox{\hrule width\wd\cals@current@cs}}}%
\setbox\rowAfter=\hbox{\box0 \unhbox\rowAfter}%
\setbox0=\hbox{\unhbox\cals@current@row \next}
% Decoration backup, typeset the first row,
% restore context, typeset the second at the end of macro
\thead{\brow \bfseries \cell{header1}\cell{header2}\cell{header3}
\mdseries \erow}
\brow \cell{\lipsum[ 1]}\cell{\lipsum[ 2]}\cell{\lipsum[ 3]} \erow
\brow \cell{\lipsum[ 4]}\cell{\lipsum[ 5]}\cell{\lipsum[ 6]} \erow
\brow \cell{\lipsum[ 7]}\cell{\lipsum[ 8]}\cell{\lipsum[ 9]} \erow
\brow \cell{\lipsum[10]}\cell{\lipsum[11]}\cell{\lipsum[12]} \erow
\brow \cell{\lipsum[13]}\cell{\lipsum[14]}\cell{\lipsum[15]} \erow
\brow \cell{\lipsum[16]}\cell{\lipsum[17]}\cell{\lipsum[18]} \erow
Copy link

ulfet commented Sep 16, 2020

This actually works, and handled my problem of having multi-page table that needs inter-row breaks.

I have one question. I would like to remove the vertical and horizontal lines dividing columns and rows. Is it doable?

Copy link

olpa commented Sep 16, 2020


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment