I'm using a custom listing environment which does not float taken from
Code spanning over two pages with minted, inside listing with caption.
The caption is done with the
The problem is that under certain circumstances the caption is on another page than the complete listing. Is there any way to prevent this behavior?
Update Here is the minimal example. Just to clarify again: It is allowed to have pagebreaks in the code, but not between code and caption. So in the example the caption should either be also on page 1 or on page 2 there should be some lines of code.