So I am writing a programming book and I decided to include `\section`s in the ToC as well (see picture below). The problem I am having is that I have ugliness where `\chapter` is the last item on the page and only on the next page I have the `\section`s for that chapter (see the very end of picture).

How can I fix ToC to move this `3 Text Conversion and Substitution` to a new page rather than leaving it hanging on the current page?

I am using `memoir` class, btw.

![wrong2](https://i.stack.imgur.com/OWGGS.png)