[texhax] nopagebreak not working

Uwe Lück uwe.lueck at web.de
Mon Apr 10 15:40:35 CEST 2006

At 20:06 08.04.06, Paul Tremblay wrote:
>The \nopagebreak is not working for me in the memoir class when I have
>the following code:
>% start example
>%converting element tei:head
>2.8. Product Manufacturers and Modernize Main Street
>\newenvironment{id2252200}{\flushright }{}
>It is only natural that the buying public should expect our stores
>and shops to be as inviting, interesting and up-to-date as the
>products on the shelves.
>% end of example
>What I am trying to do is keep my heading (title) together with the
>text that comes after. What commands are used when LaTeX uses the
>\section command to achive no page breaking, and also to ensure that
>there is a good amount of text will be kept with the title?

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).

Best regards,

More information about the texhax mailing list