ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Progressively encouraging page/column breaks at \blank with penalties
@ 2021-08-15  5:00 Joey McCollum via ntg-context
  2021-08-15  5:52 ` Aditya Mahajan via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Joey McCollum via ntg-context @ 2021-08-15  5:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Joey McCollum


[-- Attachment #1.1: Type: text/plain, Size: 2920 bytes --]

Hi,

I'm trying to implement a section break marker in a grid layout. At a
section break, two lines of space should separate the subsequent segments
of text (just plain paragraphs, in this case), and a symbol (in the example
below, "X") should be set in the middle of these two lines. For my
purposes, the section break symbol should never occur at the top of a page
or column, and it is more desirable to have a page or column end with the
section break symbol than to have a single orphaned line follow the symbol
at the end of the page or column. Based on these constraints, I thought
that using the "samepage" and "preference" options for the first and second
line breaks would work nicely:

```
\define\SectionBreak{%
    \blank[halfline, samepage]% non-breaking to ensure that no column
begins with the section break symbol
    \startalignment[middle]%
        {X}% section break symbol
    \stopalignment%
    \blank[halfline, preference]% this can (and, if possible, should) be
broken across a column
```

This does successfully prevent the placement of the symbol at the top of a
page/column, but it doesn't encourage the placement of the symbol at the
end of a page/column as often as I would like. I tried replacing the
"preference" option with options with better negative penalties, like
"penalty:-1000", "penalty:-2000", and even "penalty:-5000", but these
didn't make any difference. The option "penalty:-10000" trivially works,
but it forces a page/column break at every section break marker, which is
far too extreme.

Is this normal behavior? I would have thought that progressively more
negative penalties would gradually encourage page/column breaks, but this
doesn't seem to happen. In the following MWE, the "preference" and
"penalty" options (apart from "penalty:-10000") for the second line break
don't change the total page count or appearance of the final page at all
(which would be expected in a document of this size):

```

\setuplayout[

grid=yes %enable baseline grid

]


\setupinterlinespace[18bp] % text line spacing


%Define macro for section break:

\define\SectionBreak{%

\blank[halfline, samepage]%non-breaking to ensure that no column begins
with the section break symbol

\startalignment[middle]%

{X}% section break symbol

\stopalignment%

\blank[halfline]% a column break here is neither encouraged nor discouraged

% \blank[halfline, preference]% this should encourage a column break here,
but it doesn't seem to make a difference

% \blank[halfline, penalty:-1000]% still no difference

% \blank[halfline, penalty:-2000]% still no difference

% \blank[halfline, penalty:-5000]% still no difference

% \blank[halfline, penalty:-10000]% this works, but it is too extreme!

}


%Set things up for fakewords:

\usemodule[visual]

\setupsystem[random=10]


\starttext

\dorecurse{400}{\fakewords{20}{100}\SectionBreak}

\stoptext
```

As always, any help is appreciated!

Joey

[-- Attachment #1.2: Type: text/html, Size: 4604 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Progressively encouraging page/column breaks at \blank with penalties
  2021-08-15  5:00 Progressively encouraging page/column breaks at \blank with penalties Joey McCollum via ntg-context
@ 2021-08-15  5:52 ` Aditya Mahajan via ntg-context
  2021-08-16  0:51   ` Joey McCollum via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan via ntg-context @ 2021-08-15  5:52 UTC (permalink / raw)
  To: Joey McCollum via ntg-context; +Cc: Aditya Mahajan

On Sun, 15 Aug 2021, Joey McCollum via ntg-context wrote:

> Hi,
> 
> I'm trying to implement a section break marker in a grid layout. At a
> section break, two lines of space should separate the subsequent segments
> of text (just plain paragraphs, in this case), and a symbol (in the example
> below, "X") should be set in the middle of these two lines. For my
> purposes, the section break symbol should never occur at the top of a page
> or column, and it is more desirable to have a page or column end with the
> section break symbol than to have a single orphaned line follow the symbol
> at the end of the page or column. Based on these constraints, I thought
> that using the "samepage" and "preference" options for the first and second
> line breaks would work nicely:
> 
> ```
> \define\SectionBreak{%
>     \blank[halfline, samepage]% non-breaking to ensure that no column
> begins with the section break symbol
>     \startalignment[middle]%
>         {X}% section break symbol
>     \stopalignment%
>     \blank[halfline, preference]% this can (and, if possible, should) be
> broken across a column
> ```
> 
> This does successfully prevent the placement of the symbol at the top of a
> page/column, but it doesn't encourage the placement of the symbol at the
> end of a page/column as often as I would like. 

Depending on what you want, you can try adding \testpage[n] (where n is a number). This checks if the remainder of the page has enough space for n lines; if not, then it issues a page-break.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Progressively encouraging page/column breaks at \blank with penalties
  2021-08-15  5:52 ` Aditya Mahajan via ntg-context
@ 2021-08-16  0:51   ` Joey McCollum via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Joey McCollum via ntg-context @ 2021-08-16  0:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Joey McCollum


[-- Attachment #1.1: Type: text/plain, Size: 2282 bytes --]

That works for my purposes; thank you for letting me know about it!

Joey

On Sun, Aug 15, 2021 at 1:53 AM Aditya Mahajan via ntg-context <
ntg-context@ntg.nl> wrote:

> On Sun, 15 Aug 2021, Joey McCollum via ntg-context wrote:
>
> > Hi,
> >
> > I'm trying to implement a section break marker in a grid layout. At a
> > section break, two lines of space should separate the subsequent segments
> > of text (just plain paragraphs, in this case), and a symbol (in the
> example
> > below, "X") should be set in the middle of these two lines. For my
> > purposes, the section break symbol should never occur at the top of a
> page
> > or column, and it is more desirable to have a page or column end with the
> > section break symbol than to have a single orphaned line follow the
> symbol
> > at the end of the page or column. Based on these constraints, I thought
> > that using the "samepage" and "preference" options for the first and
> second
> > line breaks would work nicely:
> >
> > ```
> > \define\SectionBreak{%
> >     \blank[halfline, samepage]% non-breaking to ensure that no column
> > begins with the section break symbol
> >     \startalignment[middle]%
> >         {X}% section break symbol
> >     \stopalignment%
> >     \blank[halfline, preference]% this can (and, if possible, should) be
> > broken across a column
> > ```
> >
> > This does successfully prevent the placement of the symbol at the top of
> a
> > page/column, but it doesn't encourage the placement of the symbol at the
> > end of a page/column as often as I would like.
>
> Depending on what you want, you can try adding \testpage[n] (where n is a
> number). This checks if the remainder of the page has enough space for n
> lines; if not, then it issues a page-break.
>
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 3295 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2021-08-16  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-15  5:00 Progressively encouraging page/column breaks at \blank with penalties Joey McCollum via ntg-context
2021-08-15  5:52 ` Aditya Mahajan via ntg-context
2021-08-16  0:51   ` Joey McCollum via ntg-context

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