[texhax] nopagebreak not working

Uwe Lück uwe.lueck at web.de
Tue Apr 11 19:13:12 CEST 2006


At 21:17 10.04.06, Paul Tremblay wrote:

>Am I not understanding something? I assume the following code is
>correct:
>
>text text
>  \nopagebreak
>
>  more text
>
>A page break should not occur between text and more text, correct? Yet
>I have created multiple documents that show \nopagebreak doesn't work,
>simple documents with nothing unusual.

I wanted to tell: indeed this is what one would expect
and what probably was intended. However, /sometimes/
it doesn't work this way, for what you have found examples.
TeX is great in many respects, but sometimes you have
to know certain details to get what you want.
LaTeX manuals don't tell all you need for this,
often you need the TeXbook indeed
(and sometimes even this doesn't suffice).

>I can't quite get the \@beginparpenalty to work.
>
>\newenvironment{head}{}{}
>\makeatletter
>\renewenvironment{head}{\begin{center}}{\end{center}\@beginparpenalty=10000}
>\vspace{12pt}
>\makeatother
>
>\begin{head}
>MODERNIZING WITH MODERNE: LEXINGTON'S WOOLWORTH'S WONDER STORE
>\end{head}

In this case, I guess the \vspace12pt causes the break
-- because it is not preceded by that \nopagebreak.
My suggestion was not that you can prevent the page-break
just by that \@beginparpenalty10000, but that it is /necessary/
-- among other things -- or can help, together with other things.
Especially, the \@beginpenalty thing still requires \nopagebreak.

Oh -- and I see: you haven't understood me:
the \@beginparpenalty thing must be done in the
environment /following/ the heading, it is useless in the heading
itself.

All the best,
   Uwe.



More information about the texhax mailing list