groff
[Top][All Lists]
Advanced

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

Re: [Groff] Ragged Bottoms


From: Greg Pavelcak
Subject: Re: [Groff] Ragged Bottoms
Date: Tue, 25 Nov 2003 17:40:03 -0500
User-agent: Mutt/1.5.4i

On Tue, Nov 25, 2003 at 05:05:43PM -0500, Peter Schaffter wrote:
> On Tue, Nov 25, 2003, Greg Pavelcak wrote:
> > I've been trying to write some two-pass macros that measure the
> > difference between the bottom line and the desired bottom on the first
> > pass and applies the adjustments to the flexible spaces in the document
> > on the second. It really seems like thi should be easy, but I haven't
> > been having much luck. Has anyone else tried to automate ragged bottom
> > elimination in this or any other way? If you have, I'd love to hear
> > about your results.
> 
> While it isn't the precise solution to your problem, you might want
> to study om.tmac, particularly the macro TRAPS, which is where
> document leading and the bottom margin are worked out.  Very simply,
> TRAPS compares the lead supplied by the user with the bottom margin
> set by the user, counts how many lines actually fit on the page at
> the given lead, then calculates how many machine units (1/1000 pt
> for PostScript, which is what om.tmac's geared toward) to add to the
> overall leading so that the last line on the page falls precisely on
> the established bottom margin.
> 
> Another place to look for ideas is the SHIM macro, which puts the
> leading "back on track" if a user strays from it.  It does this
> simply by subtracting where one is on the current page from the next
> legal place one needs to be to ensure flush bottom margins, and
> advances the difference.
> 
> In a two-pass scenario, it should be possible to spring a trap
> near the bottom of the page, one that uses the number of times the
> flexible space macro was invoked divided into whatever space is
> left over, then outputs the first pass diversion with the appropriate
> space being given to .sp as an argument.
> 
> Applying Occam's razor at its most trenchant:
> 
> .de space
> .if \\n[#count]=0 \{\
> .   nr #count 0 1
> .\}
> \\n+[#count]
> .sp \\n[#flexible_space]u \"or whatever unit of measure you prefer
> ..
> 
> When you spring the trap near (hopefully short!) of the bottom
> margin, you invoke a macro that calculates #flexible_space by
> figuring out how much space is left over and dividing it by #count.
> This gives you #flexible_space, which, on the second "pass," is the
> value given to .sp.  Naturally, you have to remember to reset
> #count and #flexible_space for each page.
> 
> Don't take this as gospel.  It's just a quick "sketch" to point you
> in one possible direction.  My example, for instance, assumes
> you're running a version of groff that understands .sp 0.
> 
> -- 
> Peter Schaffter

Thanks very much for your informative reply. What you describe is
precisely what I've been trying to implement. I thought I had it
working for a time, then wrote in frustration when it seemed to
fail. Now I think the problem is that I haven't been testing my
macros systematically, and a careless edit eliminated zeroing of
the flexible_skip count at the start of a new page. It seems to be
working again, but now I need to go back to seeing if it copes with
changes in layout parameters.

I hadn't considered th .sp 0 problem, but I'm running (I think) a very
recent groff (1.19 on FreeBSD 5+ sources.)

Thanks again.

Greg

reply via email to

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