# When does \nopagebreak work?

There are many examples where `\nopagebreak` doesn't work as expected:

What is an example case where `\nopagebreak` does have an effect? And what are the rules determining whether or not `\nopagebreak` will work?

-

`\nopagebreak` makes it infinitely bad to break at that point. So TeX will not break at that node However it is possible that it breaks at that point visually for example

`````` blah blah

\nopagebreak
\hrule height 0pt
\pagebreak[2]

blah blah
``````

Then TeX will not break above the invisible rule, but may break after the invisible rule. So it may seem that adding `\nopagebreak` has not worked.

In complicated macros like section headings that are adding multiple penalties and spaces, each of which separately introduces a potential breakpoint it can be quite hard to prevent page breaking with a single `\nopagebreak` but the details depend on the exact details of the macro, and where it is inserting vertical space and penalties.

-
Can you give an example where the output is visually affected by a single `\nopagebreak` command? –  Ari Brodsky Sep 2 '14 at 1:48