ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Preventing page breaks (needspace)
@ 2006-06-25  2:48 Joshua Ellis
  2006-06-25  4:34 ` Aditya Mahajan
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua Ellis @ 2006-06-25  2:48 UTC (permalink / raw)


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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Preventing page breaks (needspace)
  2006-06-25  2:48 Preventing page breaks (needspace) Joshua Ellis
@ 2006-06-25  4:34 ` Aditya Mahajan
  0 siblings, 0 replies; 2+ messages in thread
From: Aditya Mahajan @ 2006-06-25  4:34 UTC (permalink / raw)


On Sat, 24 Jun 2006, Joshua Ellis wrote:

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

\testpage[4] will check if there is space for 4 lines, and would 
otherwise cause a pagebreak. I do not know how testpage compares with 
needspace defined above.

Aditya

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-06-25  4:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-25  2:48 Preventing page breaks (needspace) Joshua Ellis
2006-06-25  4:34 ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).