[NTG-context] custom header/footer for 1st/other pages of section

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Tue Aug 11 18:07:06 CEST 2020

Mike Cooper schrieb am 10.08.2020 um 23:40:
>> -----Original Message-----
>> From: ntg-context [mailto:ntg-context-bounces at ntg.nl] On Behalf Of Wolfgang
>> Schuster
>> Sent: Thursday, August 06, 2020 2:58 PM
>> To: mailing list for ConTeXt users
>> Subject: Re: [NTG-context] custom header/footer for 1st/other pages of section
>> Mike Cooper schrieb am 06.08.2020 um 17:15:
>>> Hola,
>>> I imagine this is probably simple but I can’t find it…
>>> I want the first page only of each section to have particular content in
>>> header/footer, then all the following pages to different specific
>>> content.Right now, I am manually entering it in each section.I’m hoping
>>> there’s a way to automate this; put it into the environment file for all
>>> sections.
>> Of course you can set different header/footer layouts for chapter pages.
>> With  \setupheadertexts and \setupfootertexts you set first the text
>> which should appear on regular pages.
>> To have a different text on a chapter page you can use the \definetext
>> command to set them (third first argument is the name of the setup and
>> the second argument the location). These setups than can applied to the
>> chapter with the header and footer key in \setuphead.
>> %%%% begin example
>> \setupheadertexts
>>     [Page \userpagenumber\ of \lastuserpagenumber]
>> \definetext
>>     [chapterheader]         % name
>>     [header]                 % vertical position
>>     [This is a chapter page] % content
>> \definetext
>>     [chapterfooter]
>>     [footer]
>>     [pagenumber]
>> \setuphead
>>     [chapter]
>>     [header=chapterheader,
>>      footer=chapterfooter]
>> \starttext
>> \dorecurse{10}
>>     {\expanded{\chapter{Chapter \recurselevel}}
>>      \dorecurse{\numexpr2*\recurselevel\relax}{\samplefile{knuth}}}
>> \stoptext
>> %%%% end example
>> Wolfgang
> Thank you Wolfgang!
> I tried to change your code from chapters to sections (since that's what I was already using) but it didn't work.  So, I switched my sections to chapters and it works great!  But it also caused me to run into other things I'd set up manually that I'm having to figure out---good way to learn!  Haha!

You can only set header or footer settings when the section starts on a 
new page. Permitting these two values for every section without this 
restrictions can lead to problems because there can be cases where you 
have different section levels on the same page and the setting from the 
last command on the page counts.

> One thing I *CANNOT* figure out:  I've been using \doifoddpageelse to put in a blank/empty page at the end of a section (if needed) so that new sections always start on an odd page.  This is still working with the change to chapters from sections, EXCEPT for the first chapter (after TOC)!  Totally stuck with that one...

Let me guess you divide your document into section blocks (frontmatter, 
bodymatter etc.).

When this is the case you have to first disable the page setting for 
these blocks because they interfere with the header/footer setting. To 
disable the page breaks add


to your document setups.

No you can change the settings for the page break at the begin of each 
chapter to



   1. Finishes the last page of the previous chapter
   2. Disables the header and footer for the next (empty) page
   3. Adds a empty page when necessary to start the new chapter on a 
right page


More information about the ntg-context mailing list