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 caption package.
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.
{minipage}{\textwidth}environment. Otherwise try a\nopagebreakmacro before\caption. Note that listings should AFAIK have the caption on top not below. – Martin Scharrer May 04 '12 at 13:19\nopagebreakdoes not work. // CORRECTION: I just remembered that I didn’t use minted in my master thesis (shame on me …). – Konrad Rudolph May 04 '12 at 16:22\begin{minipage}{\textwidth} <minted+caption> \end{minipage}is then the way to go. – Martin Scharrer May 04 '12 at 16:40mintedallows breaks. But\nopagebreakdoes not work. I want to allow page breaks within the code (so theminipageenvironment is no solution) but not at the end of the code before the caption. – schlamar May 07 '12 at 07:46minteddid make a comment here and even he didn't have many clues for answering. – egreg Jun 16 '12 at 19:50