Forum Bugs

Justified text leaving one word on last line

blairjanis
Forgive me if this has been reported ... using Prince 7.0. In a large number of instances the last word of a justified paragraph is leaving one word on the last line of the paragraph. It would probably look better if it left at least two words on the last line. Examples:

"The following provision apply to life insurance policies owned by our
trust"

"..................... shall withdraw at least the greater
of:"

Is there a way to avoid this or is it just how the justification algorithm works?
mikeday
We do try to avoid this, but it is impossible to avoid in every case. It's easier if hyphenation has been enabled, as then there are more line-breaking opportunities.
jim_albright
According to Chicago Manual of Style this situation is called an orphan. Not to be confused with one line of text at bottom of page with rest of paragraph on next page, which is also called an orphan. Unfortunately other sources use different vocabulary.

Cleaning up orphans is high on my need list also. The one line orphan/widow is handled by the orphan/widow property.

widows:2;
orphans:2;

Short line orphans are harder to fix. I would suggest something line

finalShortLine: 10%;

for saying that if the text is less than 10 percent of the line then try adjusting the paragraph tracking by
first tightening by 1pt and then loosening by 1pt
next tightening by 2pt and then loosening by 2pt
until you reach some upper bound for trying .... I stop around 25pt.

Some programs have range for interword spacing and a separate range for intraword spacing.
And yes this is not easy. But no one ever said what Prince is trying to accomplish is easy.

Jim Albright
Wycliffe Bible Translators

blairjanis
Thank you Mike and thank you for the clarification on terminology Jim. :)

I turned on hyphens and was not very happy with the result. I'm doing 8.5 x 11 page documents and am not using columns so the hyphens make the text less readable. If I was using columns I suppose it would look better. So I guess I currently have to choose between the "orphans" or the hyphens. I like Jim's suggestion.
adriencater
I have a case of a word hyphenating and leaving a half-word as a last-line-in-paragraph orphan:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam 
nibh euismod tincidunt ut laoreet dolore magna aliquam erat volut-
pat.


(placeholder text, not the original, sorry)

Yes, it's a tough nut to crack, some very intelligent people have worked on this exact problem: http://onlinelibrary.wiley.com/doi/10.1002/spe.4380111102/abstract and Adobe patented their algorithm: http://www.google.com/patents?vid=USPAT6510441.
jim_albright
So is this patent overlapping the TeX algorithm?

Jim Albright
Wycliffe Bible Translators

dauwhe
We worry about this, too.

A Quark Xtension called AutoPage has a feature called the short-line eliminator. You tell it how many characters constitute a short line, and how much you’re willing to adjust letter- and word-spacing to fix it. It then finds all paragraphs that end with that number of characters (or fewer) and applies tracking in increments until the short line is brought up.

Dave Cramer
jim_albright
If the paragraph is long enough, you can sometimes expand the spacing to get a pleasing look. This never works on short paragraphs though.

Jim Albright
Wycliffe Bible Translators

jim_albright
Using Mike's suggestion of adding a span to the last word I have come up with the following solution to this problem.

1. Identify the last word of paragraph. The XSLT is not trivial. I'll post if someone want to see it. Maybe someone can come up with a better solution.
2a. If paragraph is short, (like 40 characters= short run) then before last word place a regular breaking space.
2b. If paragraph is long, then before last word place a non-breaking space.

#2 forces the last line to be at least 1.5 words long with 2 words the norm. I'm still experimenting with hyphenate-after. Currently I have it set for 7 as this really discourages hyphen on last word. I may change to no hyphen on last word. I added provision for a regular breaking space when the paragraph is like 1.2 lines long as otherwise the one line would have lots of extra space in it. I will manually look at these lines and see if tightening would be in order. Princess (program that I wrote) will handle that for me easily. But at least with #2 I don't have many manual changes to do.

.last_word_in_short_run:before {content: " "; background-color: green ;}
.last_word_in_run:before {content: "\00a0"; background-color: red ;}
.last_word_in_short_run { hyphenate-before: 4; hyphenate-after: 7;  background-color: yellow ;}
.last_word_in_run { hyphenate-before: 4; hyphenate-after: 7; }


Sample text:
last_line_fix.png


Columns are unbalanced but we solve that by adjusting the tracking on paragraphs. Color added to show paragraphs adjusted.
line_fix_with_balanced_columns.png

Jim Albright
Wycliffe Bible Translators

  1. last_line_fix.png74.2 kB
  2. line_fix_with_balanced_columns.png75.4 kB