[NTG-context] Manipulating the left blank page when chapter starts on the right page

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Mon Jan 14 19:25:48 CET 2019


Jan U. Hasecke schrieb am 14.01.19 um 08:39:
> 
> Am 13.01.19 um 16:56 schrieb Wolfgang Schuster:
> 
>> Here is a example which shows how you can change the background color
>> of a empty page before the chapter title.
>>
>> \setuppagenumbering
>>    [alternative=doublesided]
>>
>> \startsetups [chapter:before]
>>    \doifoddpageelse
>>      {}
>>      {\pushbackground[page]
>>       \setupbackgrounds[page][background=color,backgroundcolor=black]
>>       \page[empty,right]
>>       \popbackground}
>> \stopsetups
>>
>> \setuphead
>>    [chapter]
>>    [page=yes,
>>     before=\directsetup{chapter:before}]
>>
>> \starttext
>>
>> \startchapter[title={Knuth}]
>> \dorecurse{10}{\samplefile{knuth}}
>> \stopchapter
>>
>> \startchapter[title={Zapf}]
>> \dorecurse{10}{\samplefile{zapf}}
>> \stopchapter
>>
>> \startchapter[title={Ward}]
>> \dorecurse{10}{\samplefile{ward}}
>> \stopchapter
>>
>> \stoptext
> 
> Thanks a lot Wolfgang!
> 
> This was just the thing I was looking for. These setups seems to be the
> golden bullet in ConTeXt but I often have difficulties to understand the
> mechanism.

If you mean the setups-environment with setups you’re wrong because this 
is only a alternative way to a command (e.g. \define\mycommand{...}).

The main point is that you finish the page before the section title and 
check on the new page whether you’re on a odd or even numbered page.

When the test tells you that you’re on a even numbered page you know 
there is a empty left page before the chapter which can be used to add 
something special.

Below is a simplified example for the method.

\starttext

\dorecurse{10}{\samplefile{knuth}}

\page

\doifoddpageelse
   {}
   {\pushbackground[page]
    \setupbackgrounds[page][background=color,backgroundcolor=red]
    \page[empty]
    \popbackground}

\dorecurse{10}{\samplefile{zapf}}

\stoptext

> I'll try to wikify this later this week.
> 
> The push-pop-background pair is mentionend in x-setups-overview together
> with some other push-pop-pairs or push single commands. Are they
> documented somewhere?

Most of these push/pop commands are used for internal stuff (or 
sometimes in styles) which means there is no documentation for them.

The purpose of them is to store the state of a command (e.g. the page 
background) before you change its values, afterwards you can just revert 
back to the previously saved state.

As these commands are no real environments they are listed as separate 
commands but it’s possible I will change this.

Wolfgang


More information about the ntg-context mailing list