how to avoid pagebreak at begin of new environment?

how to avoid pagebreak at begin of new environment?

Post by Stefan Pin » Wed, 14 Jul 2010 17:15:48


Hi all,

can somebody give me a hint how I could avoid that just the rule stays at the
end of the page?
I tried \nopagebreak at several positions but without success.

Thank you very much for your help and best regards
Stefan Pinnow


% ----- minimal example -----
\documentclass{scrbook}
\usepackage{lipsum}
\setlipsumdefault{1-5}
\usepackage[outerbars]{changebar}
\usepackage{framed}
\usepackage[framed]{ntheorem}
\newcommand*\rrrule{\rule[0.5ex]{\textwidth}{2pt}}
\theoremstyle{break}
\theoremheaderfont{\sffamily\bfseries}
\theorembodyfont{\upshape}
\theoremprework{\bigskip\noindent\rrrule\newline\cbstart\vspace{-\baselineskip}}
\theorempostwork{\nopagebreak\cbend\noindent\rrrule\bigskip}
\newtheorem{example}{Example}[chapter]

\begin{document}
\lipsum\par
\begin{example}
\lipsum[6]
\end{example}
\end{document}
 
 
 

how to avoid pagebreak at begin of new environment?

Post by Donald Ars » Thu, 15 Jul 2010 10:07:18

On Jul 13, 1:15m, "Stefan Pinnow" < XXXX@XXXXX.COM >



I don't think you are actually using the framed package here

> \theoremstyle{br>ak}
> \theoremheaderfont{\sffamily\bfs>ries}
> \theorembodyfont{\>pshape}
> \theoremprework{\bigskip\noindent\rrrule\newline\cbstart\vspace{-\baselineskip}}

Yuck. Instead of producing a blank line (via \newline) and
backspacing over it, just use \par.

What you are missing is how to tell the theorem environment to NOT
insert
a place for a page break. You do that with the "internal" command
\@nobreaktrue (it is a flag).

\theoremprework{\bigskip
\noindent\rrrule\par
\nopagebreak\cbstart
\nopagebreak\@nobreaktrue
}

You need to declare \makeatletter for this definition.

Donald Arseneau