[NTG-context] Preventing page breaks (needspace)

Joshua Ellis josh at apostate.com
Sun Jun 25 04:48:54 CEST 2006


While using \obeylines for some poetry there would sometimes be page breaks
in the middle of stanzas, even if there was very stretchy space on either
side.  So I borrowed some code from needspace.sty, basically to tell TeX I'd
be much happier w/ a ragged bottom than a break between lines:

  \def\needspace#1{%
  \begingroup
  \vskip#1\lineheight\penalty -100\vskip-#1\lineheight
  \vskip#1\lineheight\penalty 9999\vskip-#1\lineheight
  \endgroup}

So if there is a stanza of four lines that *really* shouldn't be split
across pages, it looks like this:

\needspace{4}
Line 1
Line 2
Line 3
Line 4  

However, I suspect I'm not the first person to run into this.  So my
question is if there is a more ConTeXt-y way to do this?  Or does ConTeXt
already have something to do this?




More information about the ntg-context mailing list