I'm missing something: enclosing a verbatim block in a samepage expands the previous page and moves the verbatim block to the new page, but also drags the last line of the previous paragraph with it, creating both an orphan on the previous page and a widow on the new page, right before the verbatim block:
paragraph line one bla bla etc and so on
line two bla bla etc end of paragraph
\begin{samepage}
\begin{verbatim}
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
\end{verbatim}
\end{samepage}
If I exclude the samepage then the page break happens after line 8 within the verbatim block.
When I include samepage then the previous page is stretched (not raggedbottom) to bring the verbatim block to the next page intact. BUT it also breaks the last paragraph between line one and line two, creating an orphan line on the previous page and a widow on the new page.
Why is that and how do I prevent it?
\documentclass{...}and ending with\end{document}. – Troy Jan 03 '18 at 14:10\goodbreakbefore. – Ulrike Fischer Jan 03 '18 at 14:15