Text FormattingAvoid Page Preak between Listing Border and first Line

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
knip
Posts: 2
Joined: Mon Mar 11, 2013 4:42 pm

Avoid Page Preak between Listing Border and first Line

Post by knip »

How is it possible to avoid a page break between the frame border and the first line of code as it is shown here?
listings-page-break.jpg
listings-page-break.jpg (56.6 KiB) Viewed 2694 times
Similarly, I have created a command to my examples that uses the package amsthm.

Code: Select all

\newcommand{\newExmp}[1]{
\vspace{1em}
\begin{samepage}
\hrule 
\begin{exmp}
#1
\end{exmp}
\hrule
\end{samepage}
\vspace{1em}
}
How is it possible to avoid a page break between the \hline and the first line of text (#1) and between last line of text and last \hline?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Avoid Page Preak between Listing Border and first Line

Post by localghost »

As already mentioned here, you should always provide a proper, self-contained and minimal example to make a problem comprehensible for others.

It would at least be helpful to know how you set up your listings.

And we would appreciate your feedback on proposed solutions to your questions.


Thorsten
Post Reply