How can I prevent breaks in a custom environment?
\item
is very complex. Replacing \item[]
with \par\nobreak
inserts a similarly-spaced (vertical) break yet allows control over the page breaking:
\newenvironment{Beispiel}[1][]
{% \begin{Beispiel}[<title>]
\goodbreak%
\refstepcounter{examplecounter}%
\begin{list}{}{\setlength{\rightmargin}{\leftmargin}}%
\item[{\textbf{Beispiel~\theexamplecounter:}}]#1\par\nobreak}%
{\end{list}}% \end{Beispiel}
One way would be to use the minipage
environment.
\begin{minipage}{\textwidth}
\begin{Beispiel}[A title]
\begin{tabular}{ccc}
1 & 2 & 3\\
4 & 5 & 6\\
7 & 8 & 9
\end{tabular}
\end{Beispiel}
\end{minipage}