ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Length range control of the last line of paragraph
@ 2016-03-21 19:14 Jan Tosovsky
  0 siblings, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-21 19:14 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

Dear All,

when paragraphs are separated by indenting the first line (instead of an
empty line), these rules should be followed:

(1) the last line lenght is greater than the left indent
    xxxxxxxxxxxxxxxx
    xxxx
      xxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxx

(2) the last line is shorter than block width
    xxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxx
      xxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxx


(ad 1) Some suggestions can be found in
http://tex.stackexchange.com/questions/28357/ensure-minimal-length-of-last-l
ine - but to be honest, it is not very clear to me how to apply it and even
combine with (2)

(ad 2) This can be done using \parfillskip XXpt plus 1fil (where XX is
required gap)

I'd be grateful for any command which would set this globally for all
paragraphs. Partly requested here  http://tracker.luatex.org/view.php?id=885

One could set 
(a) minimum length - default=2*indent
(b) minimum gap - default=indent
(c) minimum block width where (a) and (b) are still to be applied -
default=2*a+b

(ad c) if there are narrower blocks within the document (e.g. blockquotes),
we should still have some room for typesetting the last line content. If the
area width is insufficient, the last line would be typeset without these
(a+b) restrictions.

In meantime, any suggestion how to combine a+b manually are welcome.

Thanks, Jan

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]                       ` <017b01d18ab9$99df34e0$cd9d9ea0$@tosovsky@email.cz>
@ 2016-03-30 22:11                         ` Hans Hagen
  0 siblings, 0 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-30 22:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/30/2016 9:23 PM, Jan Tosovsky wrote:
> On 2016-03-26 Hans Hagen wrote:
>>
>> I added final|2*final|3*final|4*final
>>
>> where final is a hspace of one em by default
>>
>> the only purpose of this feature is to ensure a gap at the end (handy
>> when there is no indentation)
>>
>
> Does this settings just set \parfillskip XX plus 1fil or there is more complex magic in the background?

no magic

> I'd like to extend a description here:
> http://wiki.contextgarden.net/Paragraph_last_line_control
>
> Anyway, this related issue could be closed now:
>
> http://tracker.luatex.org/view.php?id=885
>
> Thanks, Jan
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-26 10:48                     ` Hans Hagen
  2016-03-26 13:31                       ` Jan Tosovsky
       [not found]                       ` <003f01d18763$c77c4fe0$5674efa0$@tosovsky@email.cz>
@ 2016-03-30 19:23                       ` Jan Tosovsky
       [not found]                       ` <017b01d18ab9$99df34e0$cd9d9ea0$@tosovsky@email.cz>
  3 siblings, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-30 19:23 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-26 Hans Hagen wrote:
> 
> I added final|2*final|3*final|4*final
> 
> where final is a hspace of one em by default
> 
> the only purpose of this feature is to ensure a gap at the end (handy
> when there is no indentation)
> 

Does this settings just set \parfillskip XX plus 1fil or there is more complex magic in the background?

I'd like to extend a description here:
http://wiki.contextgarden.net/Paragraph_last_line_control

Anyway, this related issue could be closed now:

http://tracker.luatex.org/view.php?id=885

Thanks, Jan


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]                       ` <003f01d18763$c77c4fe0$5674efa0$@tosovsky@email.cz>
@ 2016-03-26 22:05                         ` Hans Hagen
  0 siblings, 0 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-26 22:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users



On 3/26/2016 2:31 PM, Jan Tosovsky wrote:
> On 2016-03-26 Hans Hagen wrote:
>> On 3/25/2016 10:57 PM, Jan Tosovsky wrote:
>>> On 2016-03-25 Hans Hagen wrote:
>>>> On 3/25/2016 2:40 PM, Jan Tosovsky wrote:
>>>>> On 2016-03-24 Hans Hagen wrote:
>>>>>> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
>>>>>>>
>>>>>>> We basically need:
>>>>>>> <text><glue min-width='XX' max-width='hsize-3*indent'>
>>>>>>>
>>>>>>> and I thought this is exactly what \parfillskip ensures
>>>>>>> \parfillskip XX plus (hsize - 3*indent)
>>>>>>>
>>>>>> the fil is taken into account when calculating the best break
>>>>>> points and then the XX is fixed but plus/minus can lead to if
>>>>>> being less or more, all relative to other fill (distributed)
>>>>>>
>>>>>> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX
>>>>>> or more
>>>
>>> So the following \parfillskip specification finally seems to be
>>> what I was looking for ...
>>>
>>> \parfillskip \lastlinemingap plus \dimexpr\availablehsize-\lastlineminlength-\lastlinemingap\relax
>>>
>>
>> \parfillskip \lastlinemingap plus 1fill
>>
>> works just as well
>>
>
> I am getting slightly different results on several pages. The number of problematic cases is lower in my variant so I hope it makes still sense.
>
>> try \ward{}okay i.e. a short word at the end
>
> Hmm, I indeed tested my approach with bad example.
> Now your previous examples make more sense to me :-)
>
>> for your case i see no solution apart from heuristic lua magic
>
> Bad news. But I hope my parfillskip will work for majority cases and these problematic with words shorter than parindent+tolerance can be fixed afterwards by joining them with previous words using non-breaking space.

that is what previously posted alternative hyphenater code does: making 
sure that there are some reasonable amount of characters / words

> I'll look into your 'crap' paragraph builder lua code if this exception could be handled programmatically without touching the source file (i.e. test for short last line and treat leading whitespace as it was '~' if necessary).
>
> Jan
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-26 10:48                     ` Hans Hagen
@ 2016-03-26 13:31                       ` Jan Tosovsky
       [not found]                       ` <003f01d18763$c77c4fe0$5674efa0$@tosovsky@email.cz>
                                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-26 13:31 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-26 Hans Hagen wrote:
> On 3/25/2016 10:57 PM, Jan Tosovsky wrote:
> > On 2016-03-25 Hans Hagen wrote:
> >> On 3/25/2016 2:40 PM, Jan Tosovsky wrote:
> >>> On 2016-03-24 Hans Hagen wrote:
> >>>> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
> >>>>>
> >>>>> We basically need:
> >>>>> <text><glue min-width='XX' max-width='hsize-3*indent'>
> >>>>>
> >>>>> and I thought this is exactly what \parfillskip ensures
> >>>>> \parfillskip XX plus (hsize - 3*indent)
> >>>>>
> >>>> the fil is taken into account when calculating the best break
> >>>> points and then the XX is fixed but plus/minus can lead to if
> >>>> being less or more, all relative to other fill (distributed)
> >>>>
> >>>> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX 
> >>>> or more
> >
> > So the following \parfillskip specification finally seems to be 
> > what I was looking for ...
> >
> > \parfillskip \lastlinemingap plus \dimexpr\availablehsize-\lastlineminlength-\lastlinemingap\relax
> >
>
> \parfillskip \lastlinemingap plus 1fill
> 
> works just as well
>

I am getting slightly different results on several pages. The number of problematic cases is lower in my variant so I hope it makes still sense.

> try \ward{}okay i.e. a short word at the end

Hmm, I indeed tested my approach with bad example.
Now your previous examples make more sense to me :-)

> for your case i see no solution apart from heuristic lua magic

Bad news. But I hope my parfillskip will work for majority cases and these problematic with words shorter than parindent+tolerance can be fixed afterwards by joining them with previous words using non-breaking space.

I'll look into your 'crap' paragraph builder lua code if this exception could be handled programmatically without touching the source file (i.e. test for short last line and treat leading whitespace as it was '~' if necessary).

Jan

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]                   ` <00dd01d186e1$656dbff0$30493fd0$@tosovsky@email.cz>
@ 2016-03-26 10:48                     ` Hans Hagen
  2016-03-26 13:31                       ` Jan Tosovsky
                                         ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-26 10:48 UTC (permalink / raw)
  To: ntg-context

On 3/25/2016 10:57 PM, Jan Tosovsky wrote:
> On 2016-03-25 Hans Hagen wrote:
>> On 3/25/2016 2:40 PM, Jan Tosovsky wrote:
>>> On 2016-03-24 Hans Hagen wrote:
>>>> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
>>>>>
>>>>> We basically need:
>>>>> <text><glue min-width='XX' max-width='hsize-3*indent'>
>>>>>
>>>>> and I thought this is exactly what \parfillskip ensures
>>>>> \parfillskip XX plus (hsize - 3*indent)
>>>>>
>>>>
>>>> the fil is taken into account when calculating the best break
>>>> points and then the XX is fixed but plus/minus can lead to if
>>>> being less or more, all relative to other fill (distributed)
>>>>
>>>> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX or
>>>> more
>>>>
>>>> take this:
>>>>
>>>> \ruledhbox to 10cm {x\hskip0pt plus 1cm x}
>>>>
>>>> the skip will stretch more than 1cm
>>>
>>> I can see.
>>>
>>> But sorry for my ignorance, as far as I understand, \parfillskip
>>> is added to the end of the paragraph, so we have rather
>>> \ruledhbox to 10cm {x\hskip0pt plus 1cm} % without that 'x' at the
>>> end, so no 'glue' distribution is performed
>>
>> there is but not enough stretch so there will be a warning ... you
>> can see it from
>>
>> \ruledhbox to 10cm {x}
>> \ruledhbox to 10cm {x\hskip0pt plus 1cm}
>> \ruledhbox to 10cm {x\hskip0pt plus 1fill}
>>
>
> I get it, thanks.
>
>>> If '\parfillskip 2em plus (hsize - 3*(2em) - 2em)' is specified, I
>>> still think we should get space of width at least 2em '####' which
>>> can be extended as indicated by hyphens '-' here:
>>>
>>> emememememememememememememememememememem
>>> emememememem------------------------####
>>>
>>> So there are two last line lengths extrems:
>>> (shortest)
>>> emememememememememememememememememememem
>>> emememememem
>>>
>>> (longest)
>>> emememememememememememememememememememem
>>> emememememememememememememememememem
>>
>> you always add a 2em skip so there will never be a word touching the
>> right margin in the last line;
>
> yes, but this is my goal (!)
>
> See https://mailman.ntg.nl/pipermail/ntg-context/2016/084858.html - case (2)
>
> I am afraid I hasn't been clear enough yet.
>
>
>>> Can I somehow define command globally which takes local block widths?
>>>
>>> \parfillskip #1 plus \localhsize-#1-#2, where
>>> #1 gap width
>>> #2 shortest line width
>>
>> \availablehsize
>>
>
>
> So the following \parfillskip specification finally seems to be what I was looking for as it covers both cases in my original question:
>
> \setupindenting[yes,2em]
>
> \newdimen\lastlineminlength
> \newdimen\lastlinemingap
>
> \lastlineminlength=3em
> \lastlinemingap=1em
>
> \parfillskip \lastlinemingap plus \dimexpr\availablehsize-\lastlineminlength-\lastlinemingap\relax
>
> \edef\ward{\cldloadfile{ward}}
>
> \starttext
>
> \dorecurse{100}{
>       \hsize\dimexpr\textwidth-#1mm\relax
>       \ward  \par
>       \ward  \par
>       \startnarrower[left]
>           \ward \par
>           \ward \par
>       \stopnarrower
>       \page
> }
>
> \stoptext

try \ward{}okay i.e. a short word at the end and you'll see theh

\parfillskip \lastlinemingap plus 1fill

works just as well

> As it can be done in one place globally and in almost single line, no special new command is necessary (as requested originally).

i've removed the one|two|three and added final|2*final|3*final|4*final

where final is a hspace of one em by default

the only purpose of this feature is to ensure a gap at the end (handy 
when there is no indentation)

for your case i see no solution apart from heuristic lua magic

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-25 14:09                 ` Hans Hagen
@ 2016-03-25 21:57                   ` Jan Tosovsky
       [not found]                   ` <00dd01d186e1$656dbff0$30493fd0$@tosovsky@email.cz>
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-25 21:57 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-25 Hans Hagen wrote:
> On 3/25/2016 2:40 PM, Jan Tosovsky wrote:
> > On 2016-03-24 Hans Hagen wrote:
> >> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
> >>>
> >>> We basically need:
> >>> <text><glue min-width='XX' max-width='hsize-3*indent'>
> >>>
> >>> and I thought this is exactly what \parfillskip ensures
> >>> \parfillskip XX plus (hsize - 3*indent)
> >>>
> >>
> >> the fil is taken into account when calculating the best break 
> >> points and then the XX is fixed but plus/minus can lead to if 
> >> being less or more, all relative to other fill (distributed)
> >>
> >> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX or
> >> more
> >>
> >> take this:
> >>
> >> \ruledhbox to 10cm {x\hskip0pt plus 1cm x}
> >>
> >> the skip will stretch more than 1cm
> >
> > I can see.
> >
> > But sorry for my ignorance, as far as I understand, \parfillskip 
> > is added to the end of the paragraph, so we have rather
> > \ruledhbox to 10cm {x\hskip0pt plus 1cm} % without that 'x' at the
> > end, so no 'glue' distribution is performed
> 
> there is but not enough stretch so there will be a warning ... you
> can see it from
> 
> \ruledhbox to 10cm {x}
> \ruledhbox to 10cm {x\hskip0pt plus 1cm}
> \ruledhbox to 10cm {x\hskip0pt plus 1fill}
> 

I get it, thanks.

> > If '\parfillskip 2em plus (hsize - 3*(2em) - 2em)' is specified, I
> > still think we should get space of width at least 2em '####' which 
> > can be extended as indicated by hyphens '-' here:
> >
> > emememememememememememememememememememem
> > emememememem------------------------####
> >
> > So there are two last line lengths extrems:
> > (shortest)
> > emememememememememememememememememememem
> > emememememem
> >
> > (longest)
> > emememememememememememememememememememem
> > emememememememememememememememememem
> 
> you always add a 2em skip so there will never be a word touching the
> right margin in the last line; 

yes, but this is my goal (!)

See https://mailman.ntg.nl/pipermail/ntg-context/2016/084858.html - case (2)

I am afraid I hasn't been clear enough yet.


> > Can I somehow define command globally which takes local block widths?
> >
> > \parfillskip #1 plus \localhsize-#1-#2, where
> > #1 gap width
> > #2 shortest line width
> 
> \availablehsize
> 


So the following \parfillskip specification finally seems to be what I was looking for as it covers both cases in my original question:

\setupindenting[yes,2em]

\newdimen\lastlineminlength
\newdimen\lastlinemingap

\lastlineminlength=3em
\lastlinemingap=1em

\parfillskip \lastlinemingap plus \dimexpr\availablehsize-\lastlineminlength-\lastlinemingap\relax

\edef\ward{\cldloadfile{ward}}

\starttext

\dorecurse{100}{
     \hsize\dimexpr\textwidth-#1mm\relax
     \ward  \par
     \ward  \par
     \startnarrower[left]
         \ward \par
         \ward \par
     \stopnarrower
     \page
}

\stoptext

As it can be done in one place globally and in almost single line, no special new command is necessary (as requested originally).

Jan


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]               ` <008a01d1869b$e0b90610$a22b1230$@tosovsky@email.cz>
  2016-03-25 14:09                 ` Hans Hagen
@ 2016-03-25 16:56                 ` Hans Hagen
  1 sibling, 0 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-25 16:56 UTC (permalink / raw)
  To: ntg-context

On 3/25/2016 2:40 PM, Jan Tosovsky wrote:
> On 2016-03-24 Hans Hagen wrote:
>> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
>>>
>>> We basically need:
>>> <text><glue min-width='XX' max-width='hsize-3*indent'>
>>>
>>> and I thought this is exactly what \parfillskip ensures
>>> \parfillskip XX plus (hsize - 3*indent)
>>>
>>
>> the fil is taken into account when calculating the best break points
>> and then the XX is fixed but plus/minus can lead to if being less
>> or more, all relative to other fill (distributed)
>>
>> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX or more
>>
>> take this:
>>
>> \ruledhbox to 10cm {x\hskip0pt plus 1cm x}
>>
>> the skip will stretch more than 1cm
>
> I can see.
>
> But sorry for my ignorance, as far as I understand, \parfillskip is added to the end of the paragraph, so we have rather
> \ruledhbox to 10cm {x\hskip0pt plus 1cm} % without that 'x' at the end, so no 'glue' distribution is performed
>
> If '\parfillskip 2em plus (hsize - 3*(2em) - 2em)' is specified, I still think we should get space of width at least 2em '####' which can be extended as indicated by hyphens '-' here:
>
> emememememememememememememememememememem
> emememememem------------------------####
>
> So there are two last line lengths extrems:
> (shortest)
> emememememememememememememememememememem
> emememememem
>
> (longest)
> emememememememememememememememememememem
> emememememememememememememememememem
>
> I slightly modified your example and even with verystrict settings all seems to be fine (except too narrow blocks, which is not my use case).
>
> \showmakeup[glue]
>
> \setupindenting[yes,2em]
>
> \edef\ward{\cldloadfile{ward}}
>
> \setupalign[verystrict,hz]
>
> \starttext
> \dorecurse{100}{
>       \hsize\dimexpr\textwidth-#1mm\relax
>       \dimen0=\hsize
>       \advance\dimen0 by -8em % 3*em - 2em
>       \parfillskip 2em plus \dimen0\relax
>       \ward  \par
>       \parfillskip 2em plus \dimen0\relax
>       \ward  \par
>       \startnarrower[left]
>           \parfillskip 2em plus \dimen0\relax
>           \ward \par
>       \stopnarrower
>       \startnarrower[left]
>           \parfillskip 2em plus \dimen0\relax
>           \ward \par
>       \stopnarrower
>       \page
> }
> \stoptext
>
> The problem here this settings cannot be done globally if there are various block widths.
>
> Can I somehow define command globally which takes local block widths?
>
> \parfillskip #1 plus \localhsize-#1-#2, where
> #1 gap width
> #2 shortest line width

As expected, results are on the average worse than an occasional 
relatively short last line. One cannot expect to find good solutions 
when the solutionspace is too small.

\startluacode
function builders.paragraphs.constructors.methods.crap(head)
     local needed  = 2 * tex.parindent
     if needed > 0 then
         local maximum = tex.hsize
         local cycles  = 500
         local step    = 65536
         local done    = 0
         local tail    = node.tail(head)
         while true and done < cycles do
             local h = nodes.copy_list(head)
             local t = nodes.tail(h)
             local d, r = tex.linebreak(h)
             local l = node.tail(d)
             if d ~= l and l.subtype == nodes.listcodes.line then
                 local natural = nodes.dimensions(l.list,t.prev)
                 node.flush_list(d)
                 if natural >= needed then
                     break
                 elseif natural >= maximum then
                     break
                 else
                     local maybe = maximum - needed - done*step
                     if maybe > 0 then
                         tail.width   = maybe
                         tail.stretch = 0
                         tail.shrink  = 0
                         done = done + 1
                     else
                         break
                     end
                 end
             else
                 node.flush_list(d)
             end
         end
         if done > 0 then
             logs.report("crap","last line enforced in %i steps",done)
         end
     end
end
\stopluacode

\edef\ward {\cldloadfile{ward}}

\defineparbuilder[crap]

\starttext

     \dorecurse{20} {
         \dostepwiserecurse{0}{80}{2} {
             \indenting[##1mm,yes]
             \dontcomplain
             \setupalign[tolerant,stretch]
             \blackrule[width=\textwidth]
             \hsize=\dimexpr\textwidth-#1pt\relax
             \ward \par
             \startparbuilder[crap]%
                 \ward \par
                 \ward \par
             \stopparbuilder
             \page
         }
     }

\stoptext



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]               ` <008a01d1869b$e0b90610$a22b1230$@tosovsky@email.cz>
@ 2016-03-25 14:09                 ` Hans Hagen
  2016-03-25 21:57                   ` Jan Tosovsky
       [not found]                   ` <00dd01d186e1$656dbff0$30493fd0$@tosovsky@email.cz>
  2016-03-25 16:56                 ` Hans Hagen
  1 sibling, 2 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-25 14:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/25/2016 2:40 PM, Jan Tosovsky wrote:
> On 2016-03-24 Hans Hagen wrote:
>> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
>>>
>>> We basically need:
>>> <text><glue min-width='XX' max-width='hsize-3*indent'>
>>>
>>> and I thought this is exactly what \parfillskip ensures
>>> \parfillskip XX plus (hsize - 3*indent)
>>>
>>
>> the fil is taken into account when calculating the best break points
>> and then the XX is fixed but plus/minus can lead to if being less
>> or more, all relative to other fill (distributed)
>>
>> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX or more
>>
>> take this:
>>
>> \ruledhbox to 10cm {x\hskip0pt plus 1cm x}
>>
>> the skip will stretch more than 1cm
>
> I can see.
>
> But sorry for my ignorance, as far as I understand, \parfillskip is added to the end of the paragraph, so we have rather
> \ruledhbox to 10cm {x\hskip0pt plus 1cm} % without that 'x' at the end, so no 'glue' distribution is performed

there is but not enough stretch so there will be a warning ... you can 
see it from

\ruledhbox to 10cm {x}
\ruledhbox to 10cm {x\hskip0pt plus 1cm}
\ruledhbox to 10cm {x\hskip0pt plus 1fill}


> If '\parfillskip 2em plus (hsize - 3*(2em) - 2em)' is specified, I still think we should get space of width at least 2em '####' which can be extended as indicated by hyphens '-' here:
>
> emememememememememememememememememememem
> emememememem------------------------####
>
> So there are two last line lengths extrems:
> (shortest)
> emememememememememememememememememememem
> emememememem
>
> (longest)
> emememememememememememememememememememem
> emememememememememememememememememem
>
> I slightly modified your example and even with verystrict settings all seems to be fine (except too narrow blocks, which is not my use case).
>
> \showmakeup[glue]
>
> \setupindenting[yes,2em]
>
> \edef\ward{\cldloadfile{ward}}
>
> \setupalign[verystrict,hz]
>
> \starttext
> \dorecurse{100}{
>       \hsize\dimexpr\textwidth-#1mm\relax
>       \dimen0=\hsize
>       \advance\dimen0 by -8em % 3*em - 2em
>       \parfillskip 2em plus \dimen0\relax
>       \ward  \par
>       \parfillskip 2em plus \dimen0\relax
>       \ward  \par
>       \startnarrower[left]
>           \parfillskip 2em plus \dimen0\relax
>           \ward \par
>       \stopnarrower
>       \startnarrower[left]
>           \parfillskip 2em plus \dimen0\relax
>           \ward \par
>       \stopnarrower
>       \page
> }
> \stoptext
>
> The problem here this settings cannot be done globally if there are various block widths.

you always add a 2em skip so there will never be a word touching the 
right margin in the last line; furthermore you permit some stretch, but 
as said before this stretch is not frozen, it's a ratio relative to 
other stretch

\ruledhbox to 10cm {x\hskip2em plus 1cm x\hskip2em plus 1cm x}

so, the plus 1cm can become more than that depending on needs (onlky the 
warning is influenced

> Can I somehow define command globally which takes local block widths?
>
> \parfillskip #1 plus \localhsize-#1-#2, where
> #1 gap width
> #2 shortest line width

\availablehsize

i think that the #1 gap is irrelevant and actually makes it worse as it 
add space while you actually want it to move the other direction

anyway, this is why using a couple of non-hyphenated words or a minimum 
amount of characters makes more sense

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-24 20:54             ` Hans Hagen
@ 2016-03-25 13:40               ` Jan Tosovsky
       [not found]               ` <008a01d1869b$e0b90610$a22b1230$@tosovsky@email.cz>
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-25 13:40 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-24 Hans Hagen wrote:
> On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
> >
> > We basically need:
> > <text><glue min-width='XX' max-width='hsize-3*indent'>
> >
> > and I thought this is exactly what \parfillskip ensures
> > \parfillskip XX plus (hsize - 3*indent)
> >
> 
> the fil is taken into account when calculating the best break points
> and then the XX is fixed but plus/minus can lead to if being less 
> or more, all relative to other fill (distributed)
> 
> so, XX plus (hsize - 3*indent) is not a fixed value, it's XX or more
> 
> take this:
> 
> \ruledhbox to 10cm {x\hskip0pt plus 1cm x}
> 
> the skip will stretch more than 1cm

I can see. 

But sorry for my ignorance, as far as I understand, \parfillskip is added to the end of the paragraph, so we have rather 
\ruledhbox to 10cm {x\hskip0pt plus 1cm} % without that 'x' at the end, so no 'glue' distribution is performed

If '\parfillskip 2em plus (hsize - 3*(2em) - 2em)' is specified, I still think we should get space of width at least 2em '####' which can be extended as indicated by hyphens '-' here:

emememememememememememememememememememem
emememememem------------------------####

So there are two last line lengths extrems:
(shortest)
emememememememememememememememememememem
emememememem

(longest)
emememememememememememememememememememem
emememememememememememememememememem

I slightly modified your example and even with verystrict settings all seems to be fine (except too narrow blocks, which is not my use case).

\showmakeup[glue]

\setupindenting[yes,2em]

\edef\ward{\cldloadfile{ward}}

\setupalign[verystrict,hz]

\starttext
\dorecurse{100}{
     \hsize\dimexpr\textwidth-#1mm\relax
     \dimen0=\hsize
     \advance\dimen0 by -8em % 3*em - 2em
     \parfillskip 2em plus \dimen0\relax
     \ward  \par
     \parfillskip 2em plus \dimen0\relax
     \ward  \par
     \startnarrower[left]
         \parfillskip 2em plus \dimen0\relax
         \ward \par
     \stopnarrower
     \startnarrower[left]
         \parfillskip 2em plus \dimen0\relax
         \ward \par
     \stopnarrower
     \page
}
\stoptext

The problem here this settings cannot be done globally if there are various block widths.

Can I somehow define command globally which takes local block widths?

\parfillskip #1 plus \localhsize-#1-#2, where 
#1 gap width
#2 shortest line width

Jan

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]           ` <02cd01d18604$82a81620$87f84260$@tosovsky@email.cz>
@ 2016-03-24 20:54             ` Hans Hagen
  2016-03-25 13:40               ` Jan Tosovsky
       [not found]               ` <008a01d1869b$e0b90610$a22b1230$@tosovsky@email.cz>
  0 siblings, 2 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-24 20:54 UTC (permalink / raw)
  To: ntg-context

On 3/24/2016 8:36 PM, Jan Tosovsky wrote:
> On 2016-03-24 Hans Hagen wrote:
>> On 3/23/2016 8:14 PM, Jan Tosovsky wrote:
>>> On 2016-03-22 Hans Hagen wrote:
>>>> On 3/22/2016 9:57 PM, Jan Tosovsky wrote:
>>>>> On 2016-03-22 Hans Hagen wrote:
>>>>>> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
>>>>>>>
>>>>>>> when paragraphs are separated by indenting the first line
>>>>>>> (instead of an empty line), these rules should be followed:
>>>>>>>
>>>>>>> (2) the last line is shorter than block width
>>>>>>>         xxxxxxxxxxxxxxxx
>>>>>>>         xxxxxxxxxxxxxx
>>>>>>>           xxxxxxxxxxxxxx
>>>>>>>         xxxxxxxxxxxxxxxx
>>>>>>>
>>>>>>> (ad 2) This can be done using \parfillskip XXpt plus 1fil
>>>>>>> (where XX is required gap)
>>>>>>
>>>>>> setting the XXpt is tricky as it might lead to underful or
>>>>>> overful cases when that amount start interfering with an optimal
>>>>>> solution (as it's seen as acceptable overflow in some direction)
>>>>>
>>>>> underful or overful where? in previous lines? I am quite lost here
>>>>
>>>> \starttext
>>>>
>>>> \setupalign[tolerant,stretch]
>>>> \dorecurse{100}{
>>>>        \hsize\dimexpr\textwidth-#1pt\relax
>>>>        \parfillskip -4em plus 1 fill
>>>>        \input tufte
>>>>        \page
>>>> }
>>>>
>>>> \stoptext
>>>>
>>>> page 43
>>>
>>> In my output I can see overful of the last line on pages 38-46.
>>>
>>> How can this happen? Isn't it a clear bug?
>>>
>>> What exactly mean 'that amount start interfering with an optimal
>>> solution'? Isn't parfillskip settings taken already into an
>>> account when composing the paragraph?
>>
>> it's just a skip added at the end of the line ... so like any skip
>> and if you give it a fill that will be taken into account in
>> linebreaks (just like other fill)
>>
>> \starttext
>>
>> \dorecurse{100}{testtesttesttesttest #1 \hskip0ptplus1fill\relax}
>>
>> \stoptext
>>
>
> To be honest, I can't still decipher the reason why the line is not broken...
>
> We basically need:
> <text><glue min-width='XX' max-width='hsize-3*indent'>
>
> and I thought this is exactly what \parfillskip ensures
> \parfillskip XX plus (hsize - 3*indent)
>
> Or is it impossible in TeX to achieve such rule?

the fil is taken into account when calculating the best break points and 
then the XX is fixed but plus/minus can lead to if being less or more, 
all relative to other fill (distributed)

so, XX plus (hsize - 3*indent) is not a fixed value, it's XX or more

take this:

\ruledhbox to 10cm {x\hskip0pt plus 1cm x}

the skip will stretch more than 1cm

\ruledhbox to 10cm {x\hskip0pt plus 1cm\relax x%
                     x\hskip0pt plus 2cm\relax x}

now the glue gets distributed 1:2, so now you can guess

\ruledhbox to 10cm {x\hskip1mm plus 1cm\relax x%
                     x\hskip8mm plus 2cm\relax x}

> Are there other ways? I can think of:
> <text><space width='XX'><glue min-width='0' max-width='hsize-3*indent-XX'>
>
> But in this case that space at the end can be completely swallowed (by negative glue). I've tried it in the following example, but there is another problem from page 58 - blank line. But my TeX interpretation of the above pseudo code may be inappropriate...

you can see what glue eventually is used with:

\showmakeup[glue]

\start

\parfillskip  123pt           \relax \input tufte \par
\parfillskip  123pt plus 1fil \relax \input tufte \par
\parfillskip  123pt           \relax \input tufte \par
\parfillskip -123pt plus 1fil \relax \input tufte \par

\stop


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-23 23:21         ` Hans Hagen
@ 2016-03-24 19:36           ` Jan Tosovsky
       [not found]           ` <02cd01d18604$82a81620$87f84260$@tosovsky@email.cz>
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-24 19:36 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-24 Hans Hagen wrote:
> On 3/23/2016 8:14 PM, Jan Tosovsky wrote:
> > On 2016-03-22 Hans Hagen wrote:
> >> On 3/22/2016 9:57 PM, Jan Tosovsky wrote:
> >>> On 2016-03-22 Hans Hagen wrote:
> >>>> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> >>>>>
> >>>>> when paragraphs are separated by indenting the first line
> >>>>> (instead of an empty line), these rules should be followed:
> >>>>>
> >>>>> (2) the last line is shorter than block width
> >>>>>        xxxxxxxxxxxxxxxx
> >>>>>        xxxxxxxxxxxxxx
> >>>>>          xxxxxxxxxxxxxx
> >>>>>        xxxxxxxxxxxxxxxx
> >>>>>
> >>>>> (ad 2) This can be done using \parfillskip XXpt plus 1fil
> >>>>> (where XX is required gap)
> >>>>
> >>>> setting the XXpt is tricky as it might lead to underful or
> >>>> overful cases when that amount start interfering with an optimal
> >>>> solution (as it's seen as acceptable overflow in some direction)
> >>>
> >>> underful or overful where? in previous lines? I am quite lost here
> >>
> >> \starttext
> >>
> >> \setupalign[tolerant,stretch]
> >> \dorecurse{100}{
> >>       \hsize\dimexpr\textwidth-#1pt\relax
> >>       \parfillskip -4em plus 1 fill
> >>       \input tufte
> >>       \page
> >> }
> >>
> >> \stoptext
> >>
> >> page 43
> >
> > In my output I can see overful of the last line on pages 38-46.
> >
> > How can this happen? Isn't it a clear bug?
> >
> > What exactly mean 'that amount start interfering with an optimal
> > solution'? Isn't parfillskip settings taken already into an 
> > account when composing the paragraph?
> 
> it's just a skip added at the end of the line ... so like any skip 
> and if you give it a fill that will be taken into account in 
> linebreaks (just like other fill)
> 
> \starttext
> 
> \dorecurse{100}{testtesttesttesttest #1 \hskip0ptplus1fill\relax}
> 
> \stoptext
> 

To be honest, I can't still decipher the reason why the line is not broken...

We basically need:
<text><glue min-width='XX' max-width='hsize-3*indent'>

and I thought this is exactly what \parfillskip ensures
\parfillskip XX plus (hsize - 3*indent)

Or is it impossible in TeX to achieve such rule?

Are there other ways? I can think of:
<text><space width='XX'><glue min-width='0' max-width='hsize-3*indent-XX'>

But in this case that space at the end can be completely swallowed (by negative glue). I've tried it in the following example, but there is another problem from page 58 - blank line. But my TeX interpretation of the above pseudo code may be inappropriate...

\showmakeup

\starttext

\setupindenting[yes, 30pt]

\edef\ward{\cldloadfile{ward}}

%\setupalign[verytolerant,stretch]

\dorecurse{100}{
     \hsize\dimexpr\textwidth-#1mm\relax
     \dimen0=\dimexpr\availablehsize-3\parindent
     \advance\dimen0 by -\parindent

     \parfillskip \zeropoint plus \dimen0
     \ward\hbox to 10pt{}

     \ward\hbox to 10pt{}

     \startnarrower[left]
        \parfillskip \zeropoint plus \dimen0
        \ward\hbox to 10pt{}

        \parfillskip \zeropoint plus \dimen0
        \ward\hbox to 10pt{}

     \stopnarrower

     \page
}

\stoptext

Any idea?

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-24  2:10     ` Aditya Mahajan
@ 2016-03-24  9:47       ` Hans Hagen
  0 siblings, 0 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-24  9:47 UTC (permalink / raw)
  To: ntg-context

On 3/24/2016 3:10 AM, Aditya Mahajan wrote:
> On Tue, 22 Mar 2016, Hans Hagen wrote:
>
>> a next beta will provide three new keywords (related to n times
>> parindent filling, fwiw)
>>
>>     \startnarrower[left] \setupalign[four]  4>\the\parfillskip \ward
>> \par \stopnarrower
>>     \startnarrower[left] \setupalign[three] 3>\the\parfillskip \ward
>> \par \stopnarrower
>>     \startnarrower[left] \setupalign[two]   2>\the\parfillskip \ward
>> \par \stopnarrower
>
> I think that two, three, four are not very descriptive. An easier to
> remember interface could be \setupalign[3*parindent], etc.

- i don't wanted new keywords

- we don't scan for n* in setupalign (and "3*parindent" could be a 
keyword of course but messes the interface)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-22 13:31   ` Hans Hagen
  2016-03-23 19:47     ` Jan Tosovsky
@ 2016-03-24  2:10     ` Aditya Mahajan
  2016-03-24  9:47       ` Hans Hagen
  1 sibling, 1 reply; 27+ messages in thread
From: Aditya Mahajan @ 2016-03-24  2:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, 22 Mar 2016, Hans Hagen wrote:

> a next beta will provide three new keywords (related to n times 
> parindent filling, fwiw)
>
>     \startnarrower[left] \setupalign[four]  4>\the\parfillskip \ward 
> \par \stopnarrower
>     \startnarrower[left] \setupalign[three] 3>\the\parfillskip \ward 
> \par \stopnarrower
>     \startnarrower[left] \setupalign[two]   2>\the\parfillskip \ward 
> \par \stopnarrower

I think that two, three, four are not very descriptive. An easier to 
remember interface could be \setupalign[3*parindent], etc.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]   ` <018901d18538$3ef34c50$bcd9e4f0$@tosovsky@email.cz>
@ 2016-03-23 23:22     ` Hans Hagen
  0 siblings, 0 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-23 23:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/23/2016 8:14 PM, Jan Tosovsky wrote:
> On 2016-03-22 Hans Hagen wrote:
>> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
>>>
>>> when paragraphs are separated by indenting the first line
>>> (instead of an empty line), these rules should be followed:
>>
>> a next beta will provide a bit more control over last words
>>
>> \usemodule[art-01] \setupbodyfont[10pt]
>>
>> \definehyphenationfeatures
>>     [words-1]
>>     [rightwords=3,
>>      lefthyphenmin=4,
>>      righthyphenmin=4]>
>>
>> ...
>>
>> not uploaded yet
>
> I am impressed by your passion. Thanks for your continuous tweaking and inventing various approaches to fulfil my needs!

i added only a few lines ... the rightwords is already there for a while 
(but the rightchars is new)


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]       ` <018a01d18538$3f17eb50$bd47c1f0$@tosovsky@email.cz>
@ 2016-03-23 23:21         ` Hans Hagen
  2016-03-24 19:36           ` Jan Tosovsky
       [not found]           ` <02cd01d18604$82a81620$87f84260$@tosovsky@email.cz>
  0 siblings, 2 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-23 23:21 UTC (permalink / raw)
  To: ntg-context

On 3/23/2016 8:14 PM, Jan Tosovsky wrote:
> On 2016-03-22 Hans Hagen wrote:
>> On 3/22/2016 9:57 PM, Jan Tosovsky wrote:
>>> On 2016-03-22 Hans Hagen wrote:
>>>> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
>>>>>
>>>>> when paragraphs are separated by indenting the first line
>>>>> (instead of an empty line), these rules should be followed:
>>>>>
>>>>> (2) the last line is shorter than block width
>>>>>        xxxxxxxxxxxxxxxx
>>>>>        xxxxxxxxxxxxxx
>>>>>          xxxxxxxxxxxxxx
>>>>>        xxxxxxxxxxxxxxxx
>>>>>
>>>>> (ad 2) This can be done using \parfillskip XXpt plus 1fil
>>>>> (where XX is required gap)
>>>>
>>>> setting the XXpt is tricky as it might lead to underful or
>>>> overful cases when that amount start interfering with an optimal
>>>> solution (as it's seen as acceptable overflow in some direction)
>>>
>>> underful or overful where? in previous lines? I am quite lost here
>>
>> \starttext
>>
>> \setupalign[tolerant,stretch]
>> \dorecurse{100}{
>>       \hsize\dimexpr\textwidth-#1pt\relax
>>       \parfillskip -4em plus 1 fill
>>       \input tufte
>>       \page
>> }
>>
>> \stoptext
>>
>> page 43
>
> In my output I can see overful of the last line on pages 38-46.
>
> How can this happen? Isn't it a clear bug?
>
> What exactly mean 'that amount start interfering with an optimal solution'?
> Isn't parfillskip settings taken already into an account when composing the paragraph?
>
> Huh. I am puzzled.

it's just a skip added at the end of the line ... so like any skip ... 
and if you give it a fill that will be taken into account in linebreaks 
(just like other fill)

\starttext

\dorecurse{100}{testtesttesttesttest #1 \hskip0ptplus1fill\relax}

\stoptext





-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-22 13:31   ` Hans Hagen
@ 2016-03-23 19:47     ` Jan Tosovsky
  2016-03-24  2:10     ` Aditya Mahajan
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-23 19:47 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-22 Hans Hagen wrote:
> On 3/22/2016 11:54 AM, Hans Hagen wrote:
> > On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> > > when paragraphs are separated by indenting the first line 
> > > (instead of an empty line), these rules should be followed:
> 
> a next beta will provide three new keywords (related to n times
> parindent filling, fwiw)
> 
> \setupalign[four]
> \setupalign[three]
> \setupalign[two]
> 
> ...

Thanks for this! I'd personally prefer more self-decriptive keywords. After several months I usually forgot the original meaning. But I understand this is unacceptable:

last-line-length-greater-than-four-parindents

:-)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-22 21:46     ` Hans Hagen
@ 2016-03-23 19:14       ` Jan Tosovsky
       [not found]       ` <018a01d18538$3f17eb50$bd47c1f0$@tosovsky@email.cz>
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-23 19:14 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-22 Hans Hagen wrote:
> On 3/22/2016 9:57 PM, Jan Tosovsky wrote:
> > On 2016-03-22 Hans Hagen wrote:
> > > On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> > > >
> > > > when paragraphs are separated by indenting the first line 
> > > > (instead of an empty line), these rules should be followed:
> > > >
> > > > (2) the last line is shorter than block width
> > > >       xxxxxxxxxxxxxxxx
> > > >       xxxxxxxxxxxxxx
> > > >         xxxxxxxxxxxxxx
> > > >       xxxxxxxxxxxxxxxx
> > > >
> > > > (ad 2) This can be done using \parfillskip XXpt plus 1fil 
> > > > (where XX is required gap)
> > >
> > > setting the XXpt is tricky as it might lead to underful or 
> > > overful cases when that amount start interfering with an optimal 
> > > solution (as it's seen as acceptable overflow in some direction)
> >
> > underful or overful where? in previous lines? I am quite lost here
> 
> \starttext
> 
> \setupalign[tolerant,stretch]
> \dorecurse{100}{
>      \hsize\dimexpr\textwidth-#1pt\relax
>      \parfillskip -4em plus 1 fill
>      \input tufte
>      \page
> }
> 
> \stoptext
> 
> page 43

In my output I can see overful of the last line on pages 38-46.

How can this happen? Isn't it a clear bug?

What exactly mean 'that amount start interfering with an optimal solution'?
Isn't parfillskip settings taken already into an account when composing the paragraph?

Huh. I am puzzled.

Jan

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-22 10:54 ` Hans Hagen
  2016-03-22 13:31   ` Hans Hagen
@ 2016-03-23 19:14   ` Jan Tosovsky
       [not found]   ` <018901d18538$3ef34c50$bcd9e4f0$@tosovsky@email.cz>
  2 siblings, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-23 19:14 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-22 Hans Hagen wrote:
> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> >
> > when paragraphs are separated by indenting the first line 
> > (instead of an empty line), these rules should be followed:
> 
> a next beta will provide a bit more control over last words
>
> \usemodule[art-01] \setupbodyfont[10pt]
> 
> \definehyphenationfeatures
>    [words-1]
>    [rightwords=3,
>     lefthyphenmin=4,
>     righthyphenmin=4]> 
>
> ...
> 
> not uploaded yet

I am impressed by your passion. Thanks for your continuous tweaking and inventing various approaches to fulfil my needs!

Jan 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]   ` <01b401d1847d$798a9a00$6c9fce00$@tosovsky@email.cz>
@ 2016-03-22 21:46     ` Hans Hagen
  2016-03-23 19:14       ` Jan Tosovsky
       [not found]       ` <018a01d18538$3f17eb50$bd47c1f0$@tosovsky@email.cz>
  0 siblings, 2 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-22 21:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/22/2016 9:57 PM, Jan Tosovsky wrote:
> On 2016-03-22 Hans Hagen wrote:
>> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
>>> Dear All,
>>>
>>> when paragraphs are separated by indenting the first line (instead of
>> an
>>> empty line), these rules should be followed:
>>>
>>> (1) the last line lenght is greater than the left indent
>>>       xxxxxxxxxxxxxxxx
>>>       xxxx
>>>         xxxxxxxxxxxxxx
>>>       xxxxxxxxxxxxxxxx
>>>
>>> (2) the last line is shorter than block width
>>>       xxxxxxxxxxxxxxxx
>>>       xxxxxxxxxxxxxx
>>>         xxxxxxxxxxxxxx
>>>       xxxxxxxxxxxxxxxx
>>>
>>
>> you need to keep in mind that what would work out well for one specific
>> case will not look nice in general as the last line filling is just one
>> of the aspects ... so, your last line + following first line might look
>> okay (according to whatever rules and criteria) but then, as you also
>> need to increase the tolerance and enable stretch to permit that
>> solution to be found, the rest might look like crap
>
> I (naively) thought the last line can be somehow isolated in the engine so the parfillskip settings doesn't influence the rest (too much).

well, in order to determine what the last line is tex has to construct 
the paragraph so

x x xxxxxxxx

becoming

x              x
xxxxxxxx

would be real bad

> I understand your point.
>
>>> (ad 2) This can be done using \parfillskip XXpt plus 1fil (where
>>> XX is required gap)
>>
>> setting the XXpt is tricky as it might lead to underful or overful
>> cases when that amount start interfering with an optimal solution (as it's
>> seen as acceptable overflow in some direction)
>>
>
> underful or overful where? in previous lines? I am quite lost here :-)

\starttext

\setupalign[tolerant,stretch]
\dorecurse{100}{
     \hsize\dimexpr\textwidth-#1pt\relax
     \parfillskip -4em plus 1 fill
     \input tufte
     \page
}

\stoptext

page 43

>> it's hard to envision an interface, maybe some extra key in setupalign
>>
>> \setupindenting[big] \indenting[yes]
>>
>> \edef\ward{\cldloadfile{ward}}
>>
>> \setupalign[verytolerant,stretch]
>>
>> \dorecurse{100}{
>>       \hsize\dimexpr\textwidth-#1mm\relax
>>       \parfillskip \zeropoint plus 1fil\relax
>>       \ward  \par
>>       \parfillskip \zeropoint plus \dimexpr\availablehsize-
>> 3\parindent\relax
>>       \ward  \par
>>       \startnarrower[left]
>>           \parfillskip \zeropoint plus 1fil\relax
>>           \ward \par
>>       \stopnarrower
>>       \startnarrower[left]
>>           \parfillskip \zeropoint plus
>> \dimexpr\availablehsize-3\parindent\relax
>>           \ward \par
>>       \stopnarrower
>>       \page
>> }
>
> Wow, this is cool visualization!
>
> When \zeropoint is replaced by e.g. 2em, I have what wanted originally.
>
> Could anybody explain drawbacks of such approach? I mean especially that overful magic above. I'd like to summarize this topic on Wiki.
>
> Jan
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-22 10:16 ` Hans Hagen
@ 2016-03-22 20:57   ` Jan Tosovsky
       [not found]   ` <01b401d1847d$798a9a00$6c9fce00$@tosovsky@email.cz>
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-22 20:57 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

On 2016-03-22 Hans Hagen wrote:
> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> > Dear All,
> >
> > when paragraphs are separated by indenting the first line (instead of
> an
> > empty line), these rules should be followed:
> >
> > (1) the last line lenght is greater than the left indent
> >      xxxxxxxxxxxxxxxx
> >      xxxx
> >        xxxxxxxxxxxxxx
> >      xxxxxxxxxxxxxxxx
> >
> > (2) the last line is shorter than block width
> >      xxxxxxxxxxxxxxxx
> >      xxxxxxxxxxxxxx
> >        xxxxxxxxxxxxxx
> >      xxxxxxxxxxxxxxxx
> >
> 
> you need to keep in mind that what would work out well for one specific
> case will not look nice in general as the last line filling is just one
> of the aspects ... so, your last line + following first line might look
> okay (according to whatever rules and criteria) but then, as you also
> need to increase the tolerance and enable stretch to permit that
> solution to be found, the rest might look like crap

I (naively) thought the last line can be somehow isolated in the engine so the parfillskip settings doesn't influence the rest (too much). 

I understand your point.
 
> > (ad 2) This can be done using \parfillskip XXpt plus 1fil (where 
> > XX is required gap)
> 
> setting the XXpt is tricky as it might lead to underful or overful
> cases when that amount start interfering with an optimal solution (as it's
> seen as acceptable overflow in some direction)
> 

underful or overful where? in previous lines? I am quite lost here :-)

> it's hard to envision an interface, maybe some extra key in setupalign
> 
> \setupindenting[big] \indenting[yes]
> 
> \edef\ward{\cldloadfile{ward}}
> 
> \setupalign[verytolerant,stretch]
> 
> \dorecurse{100}{
>      \hsize\dimexpr\textwidth-#1mm\relax
>      \parfillskip \zeropoint plus 1fil\relax
>      \ward  \par
>      \parfillskip \zeropoint plus \dimexpr\availablehsize-
> 3\parindent\relax
>      \ward  \par
>      \startnarrower[left]
>          \parfillskip \zeropoint plus 1fil\relax
>          \ward \par
>      \stopnarrower
>      \startnarrower[left]
>          \parfillskip \zeropoint plus
> \dimexpr\availablehsize-3\parindent\relax
>          \ward \par
>      \stopnarrower
>      \page
> }

Wow, this is cool visualization!

When \zeropoint is replaced by e.g. 2em, I have what wanted originally.

Could anybody explain drawbacks of such approach? I mean especially that overful magic above. I'd like to summarize this topic on Wiki.

Jan

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found]   ` <01b001d18479$93c9f310$bb5dd930$@tosovsky@email.cz>
@ 2016-03-22 20:44     ` Hans Hagen
  0 siblings, 0 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-22 20:44 UTC (permalink / raw)
  To: ntg-context

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
>> \advance\dimen0 by -\parindent
>> \advance\dimen0 by -2em
>> \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
> \advance\dimen0 by -60pt
> \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

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-21 23:51 ` Rogers, Michael K
@ 2016-03-22 20:29   ` Jan Tosovsky
       [not found]   ` <01b001d18479$93c9f310$bb5dd930$@tosovsky@email.cz>
  1 sibling, 0 replies; 27+ messages in thread
From: Jan Tosovsky @ 2016-03-22 20:29 UTC (permalink / raw)
  To: 'mailing list for ConTeXt users'

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
> \advance\dimen0 by -\parindent
> \advance\dimen0 by -2em
> \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 modified it slightly, but it doesn't seem to have desired effect. The last line of third paragraph is still too short:

\starttext
\hsize 15.37cm
\input tufte

\parfillskip30pt plus 1fil
\input tufte

\dimen0\hsize
\advance\dimen0 by -60pt
\parfillskip=30pt plus \dimen0
%\tolerance=0   % strictly enforces glue dimensions/stretching - may have unwanted side effects

\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?

Jan

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
  2016-03-22 10:54 ` Hans Hagen
@ 2016-03-22 13:31   ` Hans Hagen
  2016-03-23 19:47     ` Jan Tosovsky
  2016-03-24  2:10     ` Aditya Mahajan
  2016-03-23 19:14   ` Jan Tosovsky
       [not found]   ` <018901d18538$3ef34c50$bcd9e4f0$@tosovsky@email.cz>
  2 siblings, 2 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-22 13:31 UTC (permalink / raw)
  To: ntg-context

On 3/22/2016 11:54 AM, Hans Hagen wrote:
> On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
>> Dear All,
>>
>> when paragraphs are separated by indenting the first line (instead of an
>> empty line), these rules should be followed:

a next beta will provide three new keywords (related to n times 
parindent filling, fwiw)

\starttext

\dontcomplain

\setupindenting[big] \indenting[yes]

\edef\ward{\cldloadfile{ward}}

\setupalign[verytolerant,stretch]

\dorecurse{100}{
     \startnarrower[left] \setupalign[four]  4>\the\parfillskip \ward 
\par \stopnarrower
     \startnarrower[left] \setupalign[three] 3>\the\parfillskip \ward 
\par \stopnarrower
     \startnarrower[left] \setupalign[two]   2>\the\parfillskip \ward 
\par \stopnarrower
     \page
}

\stoptext

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found] <016501d183a5$d3c48810$7b4d9830$@tosovsky@email.cz>
  2016-03-21 23:51 ` Rogers, Michael K
  2016-03-22 10:16 ` Hans Hagen
@ 2016-03-22 10:54 ` Hans Hagen
  2016-03-22 13:31   ` Hans Hagen
                     ` (2 more replies)
  2 siblings, 3 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-22 10:54 UTC (permalink / raw)
  To: ntg-context

On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> Dear All,
>
> when paragraphs are separated by indenting the first line (instead of an
> empty line), these rules should be followed:

a next beta will provide a bit more control over last words

\usemodule[art-01] \setupbodyfont[10pt]

\definehyphenationfeatures
   [words-1]
   [rightwords=3,
    lefthyphenmin=4,
    righthyphenmin=4]

\definehyphenationfeatures
   [words-2]
   [rightwords=3,
    rightchars=word,
    lefthyphenmin=4,
    righthyphenmin=4]

\definehyphenationfeatures
   [words-3]
   [rightwords=3,
    rightchars=8,
    lefthyphenmin=4,
    righthyphenmin=4]

\enabletrackers[hyphenator.visualize]

\setupalign[verytolerant,stretch]

\dontcomplain

\setuphyphenation
   [method=traditional]

\edef\tufte{\cldloadfile{tufte}}

\starttext

\dorecurse{100}{
     \hsize\dimexpr\textwidth-#1mm\relax
     \start \sethyphenationfeatures[words-1] \tufte \par
     \hsize\dimexpr\textwidth-#1mm\relax
     \start \sethyphenationfeatures[words-2] \tufte \par
     \hsize\dimexpr\textwidth-#1mm\relax
     \start \sethyphenationfeatures[words-3] \tufte \par
     \page
}

\stoptext

not uploaded yet


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found] <016501d183a5$d3c48810$7b4d9830$@tosovsky@email.cz>
  2016-03-21 23:51 ` Rogers, Michael K
@ 2016-03-22 10:16 ` Hans Hagen
  2016-03-22 20:57   ` Jan Tosovsky
       [not found]   ` <01b401d1847d$798a9a00$6c9fce00$@tosovsky@email.cz>
  2016-03-22 10:54 ` Hans Hagen
  2 siblings, 2 replies; 27+ messages in thread
From: Hans Hagen @ 2016-03-22 10:16 UTC (permalink / raw)
  To: ntg-context

On 3/21/2016 8:14 PM, Jan Tosovsky wrote:
> Dear All,
>
> when paragraphs are separated by indenting the first line (instead of an
> empty line), these rules should be followed:
>
> (1) the last line lenght is greater than the left indent
>      xxxxxxxxxxxxxxxx
>      xxxx
>        xxxxxxxxxxxxxx
>      xxxxxxxxxxxxxxxx
>
> (2) the last line is shorter than block width
>      xxxxxxxxxxxxxxxx
>      xxxxxxxxxxxxxx
>        xxxxxxxxxxxxxx
>      xxxxxxxxxxxxxxxx
>

you need to keep in mind that what would work out well for one specific 
case will not look nice in general as the last line filling is just one 
of the aspects ... so, your last line + following first line might look 
okay (according to whatever rules and criteria) but then, as you also 
need to increase the tolerance and enable stretch to permit that 
solution to be found, the rest might look like crap

it's the same for successive hyphenation and club/widow: any whole 
document setting that is done to get rid of one or two odd cases will 
often make the rest of the text look bad

this is a side effect of focusing on a specific typographical aspect 
whereby ignoring the rest combined with fully automated typesetting

of course one can have extensive discussions about how things should 
look right but one cannot ignore the text itself then: adding a few 
words or rephrasing is often a better way out

(the same applies to fonts: one can stress the virtues of some advanced 
kerning between two glyphs but at the same time be blind for the cases 
where it doesn't happen)

> (ad 1) Some suggestions can be found in
> http://tex.stackexchange.com/questions/28357/ensure-minimal-length-of-last-l
> ine - but to be honest, it is not very clear to me how to apply it and even
> combine with (2)
>
> (ad 2) This can be done using \parfillskip XXpt plus 1fil (where XX is
> required gap)

setting the XXpt is tricky as it might lead to underful or overful cases 
when that amount start interfering with an optimal solution (as it's 
seen as acceptable overflow in some direction)

> I'd be grateful for any command which would set this globally for all
> paragraphs. Partly requested here  http://tracker.luatex.org/view.php?id=885
>
> One could set
> (a) minimum length - default=2*indent
> (b) minimum gap - default=indent
> (c) minimum block width where (a) and (b) are still to be applied -
> default=2*a+b

any heuristic that works for one case will make another worse (when 
applied to a whole document)

> (ad c) if there are narrower blocks within the document (e.g. blockquotes),
> we should still have some room for typesetting the last line content. If the
> area width is insufficient, the last line would be typeset without these
> (a+b) restrictions.
>
> In meantime, any suggestion how to combine a+b manually are welcome.

it's hard to envision an interface, maybe some extra key in setupalign

\setupindenting[big] \indenting[yes]

\edef\ward{\cldloadfile{ward}}

\setupalign[verytolerant,stretch]

\dorecurse{100}{
     \hsize\dimexpr\textwidth-#1mm\relax
     \parfillskip \zeropoint plus 1fil\relax
     \ward  \par
     \parfillskip \zeropoint plus \dimexpr\availablehsize-3\parindent\relax
     \ward  \par
     \startnarrower[left]
         \parfillskip \zeropoint plus 1fil\relax
         \ward \par
     \stopnarrower
     \startnarrower[left]
         \parfillskip \zeropoint plus 
\dimexpr\availablehsize-3\parindent\relax
         \ward \par
     \stopnarrower
     \page
}

The 2*indent is not enough in most cases.

Actually, in context another mechanism can help:

\definehyphenationfeatures
   [words]
   [rightwords=3,
    lefthyphenmin=4,
    righthyphenmin=4]

\enabletrackers[hyphenator.visualize]

\setupalign[verytolerant,stretch]

\dontcomplain

\sethyphenationfeatures
   [words]

\setuphyphenation
   [method=traditional]

\dorecurse{100}{\hsize\dimexpr\textwidth-#1mm\relax \input tufte \page}

\stoptext

currently this doesn't discourage breaks between the last words but i'll 
add an option for that (chars or words in that case, that is the 
question) ... the reason for this mechanism is not so much the length 
but more the fact that one doesn't want an (even long) last word 
hyphenated.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: Length range control of the last line of paragraph
       [not found] <016501d183a5$d3c48810$7b4d9830$@tosovsky@email.cz>
@ 2016-03-21 23:51 ` Rogers, Michael K
  2016-03-22 20:29   ` Jan Tosovsky
       [not found]   ` <01b001d18479$93c9f310$bb5dd930$@tosovsky@email.cz>
  2016-03-22 10:16 ` Hans Hagen
  2016-03-22 10:54 ` Hans Hagen
  2 siblings, 2 replies; 27+ messages in thread
From: Rogers, Michael K @ 2016-03-21 23:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Perhaps this?  (I'm still better at Plain TeX than ConTeXt.)

%%%%%%%%%%%%%%%%
\starttext
\setupindenting[yes,40pt]
\dimen0=\hsize
\advance\dimen0 by -\parindent
\advance\dimen0 by -2em
\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 }

\blank
\hrule
\blank

% compare
\parfillskip=0ptplus1fill

\dorecurse{35}{wxy x } xy.\par
\dorecurse{42}{wxyz }\par
\dorecurse{26}{wxyz }

\stoptext
%%%%%%%%%%%%%%%%

- Michael

> On Mar 21, 2016, at 3:14 PM, Jan Tosovsky <j.tosovsky@email.cz> wrote:
>
> Dear All,
>
> when paragraphs are separated by indenting the first line (instead of an
> empty line), these rules should be followed:
>
> (1) the last line lenght is greater than the left indent
>    xxxxxxxxxxxxxxxx
>    xxxx
>      xxxxxxxxxxxxxx
>    xxxxxxxxxxxxxxxx
>
> (2) the last line is shorter than block width
>    xxxxxxxxxxxxxxxx
>    xxxxxxxxxxxxxx
>      xxxxxxxxxxxxxx
>    xxxxxxxxxxxxxxxx
>
>
> (ad 1) Some suggestions can be found in
> http://tex.stackexchange.com/questions/28357/ensure-minimal-length-of-last-l
> ine - but to be honest, it is not very clear to me how to apply it and even
> combine with (2)
>
> (ad 2) This can be done using \parfillskip XXpt plus 1fil (where XX is
> required gap)
>
> I'd be grateful for any command which would set this globally for all
> paragraphs. Partly requested here  http://tracker.luatex.org/view.php?id=885
>
> One could set
> (a) minimum length - default=2*indent
> (b) minimum gap - default=indent
> (c) minimum block width where (a) and (b) are still to be applied -
> default=2*a+b
>
> (ad c) if there are narrower blocks within the document (e.g. blockquotes),
> we should still have some room for typesetting the last line content. If the
> area width is insufficient, the last line would be typeset without these
> (a+b) restrictions.
>
> In meantime, any suggestion how to combine a+b manually are welcome.
>
> Thanks, Jan
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


________________________________

This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2016-03-30 22:11 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-21 19:14 Length range control of the last line of paragraph Jan Tosovsky
     [not found] <016501d183a5$d3c48810$7b4d9830$@tosovsky@email.cz>
2016-03-21 23:51 ` Rogers, Michael K
2016-03-22 20:29   ` Jan Tosovsky
     [not found]   ` <01b001d18479$93c9f310$bb5dd930$@tosovsky@email.cz>
2016-03-22 20:44     ` Hans Hagen
2016-03-22 10:16 ` Hans Hagen
2016-03-22 20:57   ` Jan Tosovsky
     [not found]   ` <01b401d1847d$798a9a00$6c9fce00$@tosovsky@email.cz>
2016-03-22 21:46     ` Hans Hagen
2016-03-23 19:14       ` Jan Tosovsky
     [not found]       ` <018a01d18538$3f17eb50$bd47c1f0$@tosovsky@email.cz>
2016-03-23 23:21         ` Hans Hagen
2016-03-24 19:36           ` Jan Tosovsky
     [not found]           ` <02cd01d18604$82a81620$87f84260$@tosovsky@email.cz>
2016-03-24 20:54             ` Hans Hagen
2016-03-25 13:40               ` Jan Tosovsky
     [not found]               ` <008a01d1869b$e0b90610$a22b1230$@tosovsky@email.cz>
2016-03-25 14:09                 ` Hans Hagen
2016-03-25 21:57                   ` Jan Tosovsky
     [not found]                   ` <00dd01d186e1$656dbff0$30493fd0$@tosovsky@email.cz>
2016-03-26 10:48                     ` Hans Hagen
2016-03-26 13:31                       ` Jan Tosovsky
     [not found]                       ` <003f01d18763$c77c4fe0$5674efa0$@tosovsky@email.cz>
2016-03-26 22:05                         ` Hans Hagen
2016-03-30 19:23                       ` Jan Tosovsky
     [not found]                       ` <017b01d18ab9$99df34e0$cd9d9ea0$@tosovsky@email.cz>
2016-03-30 22:11                         ` Hans Hagen
2016-03-25 16:56                 ` Hans Hagen
2016-03-22 10:54 ` Hans Hagen
2016-03-22 13:31   ` Hans Hagen
2016-03-23 19:47     ` Jan Tosovsky
2016-03-24  2:10     ` Aditya Mahajan
2016-03-24  9:47       ` Hans Hagen
2016-03-23 19:14   ` Jan Tosovsky
     [not found]   ` <018901d18538$3ef34c50$bcd9e4f0$@tosovsky@email.cz>
2016-03-23 23:22     ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).