ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: ntg-context@ntg.nl
Subject: Re: Length range control of the last line of paragraph
Date: Sat, 26 Mar 2016 11:48:36 +0100	[thread overview]
Message-ID: <56F66904.6030203@wxs.nl> (raw)
In-Reply-To: <00dd01d186e1$656dbff0$30493fd0$@tosovsky@email.cz>

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
___________________________________________________________________________________

  parent reply	other threads:[~2016-03-26 10:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
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
2016-03-21 19:14 Jan Tosovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F66904.6030203@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).