# Add customized text at an optional page-break

This question stems from Add text at an optional page-break only when breaking occurs and David Carlisle's excellent answer.

The question there was how to put text between tables when there is an (optional) page-break, e.g.

[ Table 1 ]
Continued on next page
---- page break ----
Continued from previous page
[ Table 2 ]


David's answer was to use a . The question I have here is if one has three or more tables, how can one insert custom text between each table when there is a page break between them. For example:

[ Table 1 ]
The result of Table 1, XYZ, is carried over to the next page.
---- page break ----
The result of Table 1 being: XYZ (for more details see the previous page)
[ Table 2 ]
The conclusion of Table 2, XYZ, is used on the next page.
---- page break ----
The conclusion of Table 2, being: XYZ, is calculated on the previous page.
[ Table 3 ]


The problem with the longtable is that the optional text must be identical between tables (i.e. one cannot customize it as between tables). Multiple longtable environments would overlap (i.e. a longtable for Table 1 + 2, and Table 2 + 3).

Is there a solution where one can have 'custom' optional text between tables that break across a page?

I would expect that a solution for tables could be extended to parboxes.

-
As I commented on an answer on this site the other day, there isn't any great reason really for LT's headers to be fixed, it only really needs then to have fixed height (otherwise it's page breaking calculations would be upset) that and the syntax used by LT lending itself to setting the table head and saving it in a box rather than saving the commands in a macro to be reset. Perhaps.... – David Carlisle Mar 8 '12 at 20:10

Perhaps something like this, uses \label so takes a few iterations to stabilize, also this version doesn't react too kindly if there isn't space to fit the "continued on next page" bit under the table as it comes on the next page, then forces a page break. probably fixable but this will get you started

\documentclass{article}

\textheight.5\textheight

\makeatletter
\newcount\bt@count

\def\breaktext#1#2{%
\par
\nobreak
\expandafter\label\expandafter{\the\bt@count bt@count}%
\edef\@tempa{\csname r@\the\bt@count bt@count\endcsname}%
\edef\@tempb{\csname r@\the\bt@count bt@count\endcsname}%
\expandafter\ifx\expandafter\relax\@tempa
\typeout{relax}%
\penalty\z@
\else
\typeout{[\@tempa][\@tempb]}%
\ifx\@tempa\@tempb
\typeout{equal}%
\penalty\z@
\else
\typeout{page break}%
#1\par\break#2\par\nobreak
\fi
\fi
\expandafter\label\expandafter{\the\bt@count bt@count}%
\nobreak
}

\begin{document}

\fbox{\parbox[c][4.5cm][c]{.25\textwidth}{ONE}}

\breaktext{table one continues\ldots}{continued from before}

\fbox{\parbox[c][4cm][c]{.25\textwidth}{TWO}}

\breaktext{table two continues\ldots}{continued from before}

\fbox{\parbox[c][6cm][c]{.25\textwidth}{THREE}}

\breaktext{table three continues\ldots}{continued from before}

\fbox{\parbox[c][1cm][c]{.25\textwidth}{FOUR}}

\breaktext{table four continues\ldots}{continued from before}

\fbox{\parbox[c][2cm][c]{.25\textwidth}{FIVE}}

\end{document}

-