# [NTG-context] Length range control of the last line of paragraph

Hans Hagen pragma at wxs.nl
Tue Mar 22 21:44:12 CET 2016

```On 3/22/2016 9:29 PM, Jan Tosovsky wrote:
> Hi Michael,
>
> On 2016-03-22 Rogers, Michael K wrote:
>>
>> Perhaps this?  (I'm still better at Plain TeX than ConTeXt.)
>>
>> %%%%%%%%%%%%%%%%
>> \starttext
>> \setupindenting[yes,40pt]
>> \dimen0=\hsize
>> \parfillskip=2em plus \dimen0
>> \tolerance=0   % strictly enforces glue dimensions/stretching - may
>> have unwanted side effects
>>
>> \dorecurse{41}{wxyz }\par
>> \dorecurse{42}{wxyz }\par
>> \dorecurse{26}{wxyz }
>>
>
> thanks, if I understand correctly, this follows my original idea to dynamically get the actual block width, simply substract indentation and use the variable for defining \parfillskip

i just added some variant to an existing setting, nothing too fancy,
just a delta of local width and some indent

> I modified it slightly, but it doesn't seem to have desired effect. The last line of third paragraph is still too short:

because there is more involved, like hyphenation, badness of other
lines, etc ... after all it is stretch, not absolute

i'm not going to waste time too much on figuring out some heuristic that
works in one case but not in the other

> \starttext
> \hsize 15.37cm
> \input tufte
>
> \parfillskip30pt plus 1fil
> \input tufte
>
> \dimen0\hsize
> \parfillskip=30pt plus \dimen0
> %\tolerance=0   % strictly enforces glue dimensions/stretching - may have unwanted side effects

well, no stretch or tolerance means that the solution space becomes
pretty small (so you might get your desired last line but a terrible n
lines before that)

and hsize is not always the best choice

(normally all these par values also depends on the global body font,
spacing, margins, etc. so it's more dynamic)

> \input tufte
>
> \parfillskip0pt plus 1fil
>
> \input tufte
>
> hsize is \the\hsize{}\par
> dimen0 is \the\dimen0{}
>
> \stoptext
>
> I disabled that tolerance as it caused overflowing the text to the margin. Was that the key for the functionality?

what key?

try to add a minus or negative plus ... the outcome differes per case

Hans

-----------------------------------------------------------------