jdw@garth.UUCP (Doug Waidhofer) (04/29/86)
I'm interested in any hacks or purchaseable software that fixes the problems of Orphans and Widows in Troff. In case you don't know what an Orphan or a Widow in text processing is: Orphan - When the last line of a paragraph ends up all alone just after a page break. Widow - When the first line of a paragraph ends up all alone just before a page break. Thanx in advance, -jdw
roy@phri.UUCP (Roy Smith) (05/03/86)
In article <312@garth.UUCP> jdw@garth.UUCP (Doug Waidhofer) writes: > I'm interested in any hacks or purchaseable software that fixes > the problems of Orphans and Widows in Troff. > We fixed widow lines by imbedding a ".ne 3" request in the paragraph macro (I think -me has this by default). Orphan lines are harder to deal with; I could see a scheme whereby you divert output in the start-paragraph macro, and have an end-paragraph macro that sees how long the paragraph is, and how much is left on the page and inserts a .bp at the right place. Yuck! -- Roy Smith, {allegra,philabs}!phri!roy System Administrator, Public Health Research Institute 455 First Avenue, New York, NY 10016
ron@brl-sem.ARPA (Ron Natalie <ron>) (05/04/86)
In article <312@garth.UUCP>, jdw@garth.UUCP (Doug Waidhofer) writes: > > Widow - When the first line of a paragraph ends up all alone > just before a page break. > Widows are easily fixed (and are in most macro packages), just do a need in your paragraph start macro. -Ron
idallen@watmath.UUCP (05/05/86)
I know of no cheap way to eliminate those stray lines at the tops of pages, but a simple addition to your local macro package can at least tell you about most pages on which they occur. Most macro packages have an internal "reset-parameters" macro that does a break then resets various format things. Modify this macro so that after the break it checks to see where you are on the current page. If you are exactly one line down from the top of the text portion of the page, you've just generated a widowed line, and you can .tm this to the user. The user can do a dry run of the document without printing it to get a list of the problem pages, then go back and edit text on the previous pages to remove the problem areas. For the -ms macros, the modification might read something like this. You have to add some complications to allow the SH/NH title macros to put one-line titles at page top without complaint, and the easiest thing to do is to catch widows at paragraph end only. Add this line to the end of the LP macro; add it to PP and IP too if necessary: .nr WI \\n% Add this line to the end of the SH macro; add it to NH too if necessary: .nr SH 1 Define an "error message" macro of some sort, such as: .de ER .tm MS MACROS: Input line \\n(.c: \\$1 .if \\n(.$>1 .tm ... \\$2 .if \\n(.$>2 .tm ... \\$3 .if \\n(.$>3 .tm ... \\$4 .if \\n(.$>4 .tm ... \\$5 .if \\n(.$>5 .tm ... \\$6 .if \\n(.$>6 .tm ... \\$7 .if \\n(.$>7 .tm ... \\$8 .. Put this at the beginning of the RT macro: .br .if \\n(WI&(\\n(SH=0) .if \\n(.z \{\ . if (\\n(.h>\\n(HM)&(\\n(WI<\\n%)&(\\n(.h<(\\n(HM+1.2v)) .ER \ "Possible single line widow at top of page '\\n(PN'" . nr WI 0 .\} .nr SH 0 \n(HM is the -ms register containing the size of the top margin. -- -IAN! (Ian! D. Allen) University of Waterloo
rcd@nbires.UUCP (05/09/86)
> > I'm interested in any hacks or purchaseable software that fixes > > the problems of Orphans and Widows in Troff. >... We fixed widow lines by imbedding a ".ne 3" request in the > paragraph macro (I think -me has this by default). This only helps sometimes. If you have a footnote in the first line of the paragraph, that can push the end-of-page trap up enough that you still end up with a widow. It's hard to do much better with troff, or any formatter where you've got a "single pass" sort of approach. > Orphan lines are harder to deal with; I could see a scheme whereby > you divert output in the start-paragraph macro, and have an end-paragraph > macro that sees how long the paragraph is, and how much is left on the page > and inserts a .bp at the right place. Yuck! And the same sort of scheme would work for the footnote-induced widow problem that I mentioned, if you could stomach writing the macros and ensuring that nothing gets screwed up when the diversion is re-read, etc. The use of diversions gives you a second "pass" of limited range. The really painful part (ref. "Yuck!" above) is having to process all the text twice just to get the page breaks right. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Cerebus for dictator!