Let suppose that I have an environment \begin{sol} ... \end{sol}
for writing solutions of exercises in a test. For practical reasons, I would like that two or more solutions can be put in the same page only if their whole contents are only in this page.
For example, if the solutions of exercises 1 and 2 are only in the page, they can be put together, but if not, the solution 1 must be alone, and then the solution 2 must starts at a new page.
The main problem is that the sizes of the solutions are not fixed, and they can be smaller or not that one page. It can have one small solution followed by another small one, or not.
The number of solutions is not fixed neither. Indeed, in reality I need less than 10 solutions.
Exercise 1
, a back return and then the text of the solution.\filbreak
(from plain TeX) between each chunk, it should behave the way you want. See TeXbook page 111. So a minimal answer is\newenvironment{sol}{}{\filbreak}