ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] penalties
@ 2024-10-10 12:54 Henning Hraban Ramm
  2024-10-10 14:40 ` [NTG-context] penalties Wolfgang Schuster
  2024-10-10 15:45 ` Mikael Sundqvist
  0 siblings, 2 replies; 6+ messages in thread
From: Henning Hraban Ramm @ 2024-10-10 12:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Yesterday I learned:

\startsetups[*default]
\widowpenalties 3 10000 1000 0
\clubpenalties 3 10000 1000 0
\orphanpenalties 2 8000 1000
\stopsetups

If I want the penalty settings applied to “everything” (after defining 
the layout, I think?), then I need the setup "*defaults".

Since TeX uses a club against orphans (brutal!), I’m not sure what 
\orphanpenalty is for.

I remember \twinpenalty is against doubled words (below each other?), 
and \toddlerpenalty against single letter words at the end of a line 
(why “toddler”?).

widows and clubs get only 150 in TeX, but 2000 in ConTeXt, as far as I 
could find.

Are there more penalties that make sense to set individually?

WRT demerits: Did I understand correctly that demerits are the “sum” 
(some formula) of badness and penalties in a line or paragraph?

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

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: penalties
  2024-10-10 12:54 [NTG-context] penalties Henning Hraban Ramm
@ 2024-10-10 14:40 ` Wolfgang Schuster
  2024-10-10 15:45 ` Mikael Sundqvist
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Schuster @ 2024-10-10 14:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Henning Hraban Ramm

Henning Hraban Ramm schrieb am 10.10.2024 um 14:54:
> Yesterday I learned:
> 
> \startsetups[*default]
> \widowpenalties 3 10000 1000 0
> \clubpenalties 3 10000 1000 0
> \orphanpenalties 2 8000 1000
> \stopsetups
> 
> If I want the penalty settings applied to “everything” (after defining 
> the layout, I think?), then I need the setup "*defaults".
> 
> Since TeX uses a club against orphans (brutal!), I’m not sure what 
> \orphanpenalty is for.

%%%% begin primitives.tex
[...]

\startnewprimitive[title={\prm {orphanpenalties}}]

This an (single entry) array parameter: first the size is given followed 
by that amount of penalties. These penalties are injected before spaces, 
going backward from the end of a paragraph. When we see a math node with 
a penalty set then we take the max and jump over a (preceding) skip.

\stopnewprimitive

\startnewprimitive[title={\prm {orphanpenalty}}]

This penalty is inserted before the last space in a paragraph, unless 
\prm {orphanpenalties} mandates otherwise.

\stopnewprimitive

[...]
%%%% end primitives.tex

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

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: penalties
  2024-10-10 12:54 [NTG-context] penalties Henning Hraban Ramm
  2024-10-10 14:40 ` [NTG-context] penalties Wolfgang Schuster
@ 2024-10-10 15:45 ` Mikael Sundqvist
  2024-10-10 16:44   ` Henning Hraban Ramm
  1 sibling, 1 reply; 6+ messages in thread
From: Mikael Sundqvist @ 2024-10-10 15:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

On Thu, Oct 10, 2024 at 2:58 PM Henning Hraban Ramm <texml@fiee.net> wrote:
>
> Yesterday I learned:
>
> \startsetups[*default]
> \widowpenalties 3 10000 1000 0
> \clubpenalties 3 10000 1000 0
> \orphanpenalties 2 8000 1000
> \stopsetups
>
> If I want the penalty settings applied to “everything” (after defining
> the layout, I think?), then I need the setup "*defaults".

Yes, for now, since it got reset when \setuplayout was done. But we
are working on making it possible to also setup this with \setupalign,
with a few "reasonable" pre-defined setups. So, for example in my math
book I currently run

\setupalign[lesswidows,lessclubs,lessorphans,strictmath]

and that actually makes a few of these setups. It will of course be
possible to define your own set of penalties and use them instead.

>
> Since TeX uses a club against orphans (brutal!), I’m not sure what
> \orphanpenalty is for.

Wolfgang already explained this, but in short they are there to
discourage that a paragraph ends with only one word. We looked at it
yesterday at the meeting. You saw those penalties in action when you
did \showmakeup[hpenalty].

>
> I remember \twinpenalty is against doubled words (below each other?),
> and \toddlerpenalty against single letter words at the end of a line
> (why “toddler”?).

Indeed. Well, you can imagine a little toddler not really being able
to join the rest, or if you want, tied to the rest.

>
> widows and clubs get only 150 in TeX, but 2000 in ConTeXt, as far as I
> could find.
>
> Are there more penalties that make sense to set individually?

If you do math there might be more (set above by strictmath), but I
think you are fine with the ones above. Since you are finishing a
project, please tell if more problems show up. We can have another
chat where we try to solve...

>
> WRT demerits: Did I understand correctly that demerits are the “sum”
> (some formula) of badness and penalties in a line or paragraph?

A bit like that. For each possible breakpoint you get a badness value.
Then you can see it as if TeX runs over the paragraph once more, given
all possible breakpoints, with or without extra penalties, and builds
up a demerits for the different possible solutions. They can come from
badness, penalties and additional demerits (adjdemerits not to have
incompatible lines for example). Then, at the end, the best solution
(least demerits) is the one that will be used.

We are currently writing an article on the parbuilder, with and
without parpasses. You saw an early draft at the meeting yesterday.

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

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: penalties
  2024-10-10 15:45 ` Mikael Sundqvist
@ 2024-10-10 16:44   ` Henning Hraban Ramm
  0 siblings, 0 replies; 6+ messages in thread
From: Henning Hraban Ramm @ 2024-10-10 16:44 UTC (permalink / raw)
  To: ntg-context

Thank you both, that clears up everything I wanted to know (so far).

Yesterday it was just too fast to really understand everything, and I 
got confused since the typographical term is “widows and orphans”, but 
TeX uses \cubpenalties for orphans.

I’m looking forward to the article!

I just re-did the page breaking for our current novel, “Gesicht zur 
Wand”, 452 pages so far; the last third is still in the works between 
author and editors.
With the better penalties setup, I need much less manual tweaking – but 
of course it’ll never be perfect. (Still better than our printshop’s 
cutting…)

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

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: penalties
  2024-10-31 20:33 ` [NTG-context] penalties Hans Hagen
@ 2024-11-04  9:05   ` Thomas Meyer
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Meyer @ 2024-11-04  9:05 UTC (permalink / raw)
  To: ntg-context

Hi Hans,

thank you very much for your help.
The version
\startsetups[mypenalties] ...
seemed to work better. Then I have tried
\specificationdef \MyWidowPenalties \widowpenalties 3 10000 10000 0
\specificationdef \MyClubPenalties \clubpenalties 3 10000 10000 0 ...
and it was even better.
However, I can no longer evaluate what works really well, as a new 
problem has arisen (after the last update?):
On one page I still have 18 empty lines at the bottom. On the next page 
there is a paragraph with a picture on the right that only takes up 13 
lines. Then more text. I don't know how to get the paragraph with the 
image onto the previous page.

Greetings
Thomas


Am 31.10.24 um 21:33 schrieb Hans Hagen:
> On 10/31/2024 7:26 PM, Thomas Meyer wrote:
>> Hi folks,
>>
>> following today's update,
>>
>> \startsetups[grid][mypenalties]
>>      \setdefaultpenalties
>>      \setpenalties\widowpenalties{2}{10000}
>>      \setpenalties\clubpenalties {2}{10000}
>> \stopsetups
>>
>> \setuplayout[grid=yes, setups=mypenalties]
>
> does
>
> \startsetups[mypenalties]
>      \setdefaultpenalties
>      \setpenalties\widowpenalties{2}{10000}
>      \setpenalties\clubpenalties {2}{10000}
> \stopsetups
>
> work? this [grid] was only used for this case and has been dropped in 
> favour of more powerful par passes and specification definitions
>
> this setup approach was also sensitive for order
>
>> doesn't work any longer, I think. Can anyone confirm this. There is 
>> another problem (page break in the paragraph) that I have yet to verify. 
>
> We now have so call \specificationdef's that work as shown below:
>
> \starttext
>
> \showmakeup[vpenalty]
>
> \specificationdef \MyWidowPenalties \widowpenalties 3 10000 10000 0
> \specificationdef \MyClubPenalties  \clubpenalties  3 10000 10000 0
>
> { \samplefile {tufte} } \page
>
> { \MyWidowPenalties \MyClubPenalties  \samplefile {tufte} }  \page
>
> { \lesswidowpenalties \lessclubpenalties  \samplefile {tufte} } \page
>
> { \setupalign[lesswidows,lessclubs,lessorphans] \samplefile {tufte} }  
> \page
>
> \stoptext
>
> predefined new alignment keys are:
>
> defaultwidows defaultclubs defaultbroken
>
> lesswidows lessclubs lessbroken
>
> lessorphans lessorphans:2 lessorphans:3 lessorphans:4
>
> strictwidows strictwidows:2 strictwidows:3 strictwidows:4
> strictclubs  strictclubs:2  strictclubs:3  strictclubs:4
>
> strictbroken
>
> so a 'global' setupalign can be used
>
> Hans
>
>
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>        tel: 038 477 53 69 | www.pragma-ade.nl | 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 / 
> https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net 
> (mirror)
> archive  : https://github.com/contextgarden/context
> wiki     : https://wiki.contextgarden.net
> ___________________________________________________________________________________ 
>

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

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: penalties
  2024-10-31 18:26 [NTG-context] penalties Thomas Meyer
@ 2024-10-31 20:33 ` Hans Hagen
  2024-11-04  9:05   ` Thomas Meyer
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2024-10-31 20:33 UTC (permalink / raw)
  To: ntg-context

On 10/31/2024 7:26 PM, Thomas Meyer wrote:
> Hi folks,
> 
> following today's update,
> 
> \startsetups[grid][mypenalties]
>      \setdefaultpenalties
>      \setpenalties\widowpenalties{2}{10000}
>      \setpenalties\clubpenalties {2}{10000}
> \stopsetups
> 
> \setuplayout[grid=yes, setups=mypenalties]

does

\startsetups[mypenalties]
      \setdefaultpenalties
      \setpenalties\widowpenalties{2}{10000}
      \setpenalties\clubpenalties {2}{10000}
\stopsetups

work? this [grid] was only used for this case and has been dropped in 
favour of more powerful par passes and specification definitions

this setup approach was also sensitive for order

> doesn't work any longer, I think. Can anyone confirm this. There is 
> another problem (page break in the paragraph) that I have yet to verify. 

We now have so call \specificationdef's that work as shown below:

\starttext

\showmakeup[vpenalty]

\specificationdef \MyWidowPenalties \widowpenalties 3 10000 10000 0
\specificationdef \MyClubPenalties  \clubpenalties  3 10000 10000 0

{ \samplefile {tufte} } \page

{ \MyWidowPenalties \MyClubPenalties  \samplefile {tufte} }  \page

{ \lesswidowpenalties \lessclubpenalties  \samplefile {tufte} }  \page

{ \setupalign[lesswidows,lessclubs,lessorphans] \samplefile {tufte} }  \page

\stoptext

predefined new alignment keys are:

defaultwidows defaultclubs defaultbroken

lesswidows lessclubs lessbroken

lessorphans lessorphans:2 lessorphans:3 lessorphans:4

strictwidows strictwidows:2 strictwidows:3 strictwidows:4
strictclubs  strictclubs:2  strictclubs:3  strictclubs:4

strictbroken

so a 'global' setupalign can be used

Hans



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-11-04  9:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-10 12:54 [NTG-context] penalties Henning Hraban Ramm
2024-10-10 14:40 ` [NTG-context] penalties Wolfgang Schuster
2024-10-10 15:45 ` Mikael Sundqvist
2024-10-10 16:44   ` Henning Hraban Ramm
2024-10-31 18:26 [NTG-context] penalties Thomas Meyer
2024-10-31 20:33 ` [NTG-context] penalties Hans Hagen
2024-11-04  9:05   ` Thomas Meyer

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).