Is it possible to prevent lstlisting
from splitting a code between pages if it does not fit on one page? Instead splitting I would like to have the code on the next page.
I tried to put all lstlisting
inside \begin{figure}[h!]...\end{figure}
but the order of code and header is lost.
Best Answer
Define your own listing environment which doesn't allow page breaks
or use the
float
option from the package (see documentation)