[texhax] nopagebreak not working

Paul Tremblay phthenry at iglou.com
Mon Apr 10 21:17:22 CEST 2006


On Mon, Apr 10, 2006 at 03:40:35PM +0200, Uwe Lück wrote:
> 
> I had similar problems in recent months and years, and now I know.
> 
> \flushright through \item places a penalty above "It is only natural ...",
> which is usually negative. TeX may break pages at that negative
> penalty (TeXbook p. 110). A \nobreak penalty "nearby" is overridden
> -- cf. Exercise 14.9f. of the TeXbook.
> 
> You could use \raggedleft instead of \flushright. This doesn't
> insert any glue or penalty above, though you get flushing right
> and the version of \\ that is typical for the flushright environment.
> 
> More generally, sometimes the samepage environment helps,
> but has been somewhat deprecated. The penalty relevant for
> your application is \@beginparpenalty, and you could somehow
> set it to 10000 locally, e.g.: at the start of the environment, inside.
> 
> LaTeX uses \@afterheading to prevent the next \item from
> placing \@beginparpenalty -- through a certain mechanism
> of switching \if at nobreak You could finish the definition of
> your head environment with \@afterheading (provided you
> know about \makeatletter and \makeatother).
> 

I played around with some more examples that don't involve the
\flushright environment at all and get the same exact problem. It
seems from my experimentation that the \nopagebreak[4] doesn't work at
all. I can create test documents in which the page breaks exactly at
the \nopagebreak command using both the article and the memoir class. 

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 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}

Is this what you meant? 

Thanks

Paul


-- 

************************
*Paul Tremblay         *
*phthenry at iglou.com    *
************************


More information about the texhax mailing list