How to let a (sub)section be placed on a new page if the previous page is more than x% filled?

Duplicate of

Thanks for pointing it out @bluss! @joffdd, feel free to flag my reply/message me if you think this is an error.