I would like to be able to test whether a paragraph has one or more page breaks. If it does, I would like to print text immediately after each break. In some cases a paragraph may not have a break; in other cases there may be one or more breaks. I understand this would probably require wrapping in an environment or macro.
Answers to similar questions have suggested using counters to compare page numbers. This allows me to determine whether there is a break, but is not useful for inserting text after that break (and I can't see it working if there were multiple breaks).
Including an example is difficult because it's just a paragraph of text, but here's an attempt:
\testifbreak{Cras mattis consectetur purus sit amet fermentum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec sed odio dui. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus.}
What I would like this to do is test if that chunk of text extends over a page. If it does not, it would just print the text as-is. If it did extend over the page I would like it to print something like:
Cras mattis consectetur purus sit amet fermentum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec sed odio dui. Maecenas
CONTINUED
sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus.
On each subsequent page, I would like it to print 'CONTINUED' if the text goes over the page.
Help is greatly appreciated!
EDIT
I edited the above question on the suggestion of @DavidCarlisle, who indicated it was unclear (and on reflection I agree that it was).
@TeXnician provided an example using tcolorbox
in their answer which worked perfectly. Many thanks for that!
\afterpage
does what you want. (from the package of that name)\afterpage
prints the inserted text on the page after the paragraph, but I need it at the top of the same page.\afterpage{CONTINUED ... the inserted text .... }
would do.