groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Short Orphan Lines


From: Larry Kollar
Subject: Re: [Groff] Short Orphan Lines
Date: Thu, 25 Mar 2004 20:52:08 -0500

Perhaps you could put the paragraph into a diversion and check the amount of space left on the page before printing it. Something like this (I haven't tested):

        .de Para
        .ne 3
        .sp \\n[PD]u
        .\" whatever else you want to do at the beginning of a paragraph...
        .di Pdiv
        ..

        .de EndPara
        .di
.if \\n[.t] < \\n[dn]-2v \{\ \" .t = space to next trap, dn = diversion height . dt \\n[.h]u+\\n[dn]u-2v EarlyBreak
        .\}
        .Pdiv           \" print the paragraph
        .\" whatever else needs to be done at the end of a paragraph
        ..

        .de EarlyBreak
        .bp
        .\" reset the footer trap if the header trap doesn't do it
        ..

Then you would wrap paragraphs with problem breaks like this...

        .Para
        This is the text of the paragraph.
        We want at least the last two lines to be on the same page.
        More stuff.
        .EndPara

You might also want to check the archives; Thomas Baruchel posted
some code in March 2001 that might work for you.
--
Larry Kollar     k  o  l  l  a  r  @  a  l  l  t  e  l  .  n  e  t
Unix Text Processing: "UTP Revival"
http://home.alltel.net/kollar/utp/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]