# How to omit numbering in the last page of every chapter

I am writing a fiction work with ConTeXt.

Every chapter and my four parts pages begin with their corresponding odd page. I have no problem with every last chapter page containing the text: whether was an odd or an even page, they do not have their related numbering in the footer, and the blank odd last pages have empty header too.

So far, that performance is almost what I need, and what I get thanks to Aditya's and Wolfgang's help. I know that this requirement may appear a very particular option, but it is a common practice among most of the fiction Spanish writings, and it is a must for me too.

Why I wrote almost? Because of the same error: unfortunately, there is always an exception in my last chapter, every time.

As I said, I have been messing around with my setup thanks to the guys here.

\setuppagenumbering
[alternative=doublesided,
location=]

\setupfootertexts[][pagenumber]

%\unprotect
%\installpagebreakmethod {ebohoyod}
%  {\page_otr_command_flush_all_floats
%   \doifoddpageelse
%      {\page_otr_command_next_page_and_inserts
%       \setupfooter[state=empty]%
%       \page_reset_marks_and_insert_dummy}
%      {\setupfooter[state=empty]%
%       \page_otr_command_next_page_and_inserts}}
%\protect

before={\blank[force,34pt]},
after={\blank[114pt]}]

before={\blank[force,154pt]}\hskip 4pt]


Because of my ignorance, I tried several combinations. For example, if I comment out the \unprotect code, the performance is good in the even pages, but it fails in the all the odd pages.

Speaking of my lack of resources, I do not know if my short body text setup may be of aid. I record my frontmatter files and my chapters as \input, but I have set up my part pages directly. I can see here any interference with my preamble setup, but, just in case.

\starttext

\startfrontmatter
\input /frontmatter/cover-verso.tex
\input /frontmatter/tit-auth-edit.tex
\input /frontmatter/epigraph.tex
\stopfrontmatter

\startbodymatter
\startpart
[title={C\switchtobodyfont[indpart]uentos grises}]
\setlayer
[yinyang]
[x=106pt,y=200pt]
{\externalfigure[GloucesterCathedral][width]}
\input /bodymatter/relato1.tex
\input /bodymatter/relato2.tex
\stoppart

\startpart
[title={C\switchtobodyfont[indpart]uentos verdes}]
\setlayer
[yinyang]
[x=106pt,y=200pt]
{\externalfigure[GloucesterCathedral][width]}
\input /bodymatter/relato3.tex
\input /bodymatter/relato4.tex
\stoppart

\startpart
[title={C\switchtobodyfont[indpart]uentos azules}]
\setlayer
[yinyang]
[x=106pt,y=200pt]
{\externalfigure[GloucesterCathedral][width]}
\input /bodymatter/relato5.tex
\input /bodymatter/relato6.tex
\stoppart

\startpart
[title={C\switchtobodyfont[indpart]uentos rojos}]
\setlayer
[yinyang]
[x=106pt,y=200pt]
{\externalfigure[GloucesterCathedral][width]}
\input /bodymatter/relato7.tex
\input /bodymatter/relato8.tex
\stoppart
\stopbodymatter

\startbackmatter
\startstandardmakeup[doublesided=yes]
\setupinterlinespace[line=18pt]
\completecontent[criterium=all]
\blank[280pt]
\stopstandardmakeup
\stopbackmatter

\stoptext

• Welcome to TeX.SX! It's a reasonable question. It would be easier for us to experiment if you edited your question and added a minimal working example that compiles and demonstrates your problem. In particular, the document class that you are using is almost certainly relevant. – Andrew Oct 30 '18 at 0:50
• Document class with ConTeXt? I do not understand you. But I will post my code. – ebohoyod Oct 30 '18 at 1:07
• "A must" in fiction writings? I have not read fiction novels for centuries, but I have just check a few that I have still unread at home and it seems that still some people that do not take care of this. Besides, I personally doubt that this could be of some benefit for the reader. – Fran Oct 30 '18 at 17:42
• Is the Ceuntos Verdes page a new part? If so, you'd have to add \setuphead[part][page=...] similar to the setup for chapter. – Aditya Oct 31 '18 at 4:21
• Then Wolfgang's suggestion to add the page option to setupsectionblock will work – Aditya Nov 1 '18 at 13:24

# Settings for the page break

Use the order of the keywords for the page (or as argument for the \definepagebreak command) of the \setuphead command.

\setuppagenumbering
[alternative=doublesided,
location={footer,right}]

%   [chapter]

[chapter]
[page=chapter]

\starttext

\chapter{Knuth}

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

\chapter{Zapf}

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

\chapter{Ward}

\dorecurse{5}{\samplefile{ward}}

\stoptext


# Extended example for the whole document

The following example includes also the settings which you have to apply to get the correct results when you add \part headers and sectionblocks which add additional page break.

Especially the sectionblock settings are necessary because the finish the chapters before the next \part can use the correct settings for the page break.

\setuppagenumbering
[alternative=doublesided,
location=none]

[style={\switchtobodyfont[10pt]\it}]

[] [part]
[chapter] []

\setupfootertexts
[] [pagenumber]

[part]
[page=ebohoyod,
number=no,
alternative=middle,
footer=empty]

[title,chapter]
[page=ebohoyod,
number=no,
alternative=middle,

\setupsectionblock
[page=ebohoyod]

\setuppapersize [A5] [A5]

\starttext

\startfrontmatter

\startstandardmakeup [align=middle,pagestate=start]

{\tfd Sample document}

\stopstandardmakeup

\stopfrontmatter

\startbodymatter

\startpart [title={First part}]

\startchapter [title={Chapter One}]
\dorecurse{4}{\samplefile{douglas}}
\stopchapter

\startchapter [title={Chapter Two}]
\dorecurse{4}{\samplefile{waltham}}
\stopchapter

\stoppart

\startpart [title={Second part}]

\startchapter [title={Chapter Three}]
\dorecurse{4}{\samplefile{dawkins}}
\stopchapter

\startchapter [title={Chapter Four}]
\dorecurse{4}{\samplefile{carey}}
\stopchapter

\stoppart

\stopbodymatter

\startappendices

\completecontent

\stopappendices

\stoptext

• Yes, Wolfgang, your result is what I am seeking. But I still see nothing wrong in my above-transcribed code. It is frustrating. Nevertheless, I will post another graphic example with the "good news" and the "bad news" mentioned above to Aditya. I sense I am missing a very, very little detail. – ebohoyod Oct 30 '18 at 20:46
• My issue is almost solved, but not yet. Would you mind doing me the favour of reviewing my update? – ebohoyod Nov 1 '18 at 4:43

Furthermore, I put at the end of all whatever.tex chapters the \page[empty] command before \stopchapter. Why? Because I want the last even page without headers and footers when these pages does not have text.

Of course, when the last even page does have text, I comment the \page[empty] command in the pertinent chapter.

The right way to do this is to define a page break that removes the headers and footers:

\definepagebreak[chapterbreak]



However, this does not address your second question. For that, I define a new page break that checks if one is on an odd or an even page and disables the header and footer accordingly.

\unprotect
\installpagebreakmethod {ebohoyod}
{\page_otr_command_flush_all_floats
\doifoddpageelse
{\page_otr_command_next_page_and_inserts
\setupfooter[state=empty]%
\page_reset_marks_and_insert_dummy}
{\setupfooter[state=empty]%
\page_otr_command_next_page_and_inserts}}
\protect



Here is a complete example. Note that I had used \setupfootertexts to add page numbers in the footer rather than \setuppagenumbering.

\setuppagenumbering
[alternative=doublesided, location=]

\setupfootertexts[][pagenumber]

\unprotect
\installpagebreakmethod {ebohoyod}
{\page_otr_command_flush_all_floats
\doifoddpageelse
{\page_otr_command_next_page_and_inserts
\setupfooter[state=empty]%
\page_reset_marks_and_insert_dummy}
{\setupfooter[state=empty]%
\page_otr_command_next_page_and_inserts}}
\protect

\starttext

\startpart[title=Part one]
\startchapter
[title=Test chapter]

Page 1

\stopchapter

\startchapter
[title=Test chapter]

Page 1 \page
Page 2

\stopchapter

\startchapter
[title=Test chapter]

Page 1 \page
Page 2 \page
Page 3

\stopchapter

\startchapter
[title=Test chapter]

Page 1 \page
Page 2 \page
Page 3 \page
Page 4

\stopchapter
\stoppart
\stoptext


Here is a chapter when the previous chapter ended on an odd page:

and here is a chapter when the previous chapter ended on an even page

• My bad, Aditya. No more \page[empty], commented or not, at the end of chapters. I recognise it was not the best way. In order to not change my novel's look, I have modified your example, but taking care of your code. The good news: some last pages have no numbering. The bad news: I do not see any constant pattern about the error pages. It seems an apparently random performance, but I know this can not be true: I am missing something here. I have changed my above previous code sample. Is there something wrong with it? – ebohoyod Oct 30 '18 at 16:57
• Did you change the page numbering to use \setupfooter rather than the location parameter of \setuppagenumbering? You'd have to create a minimal example demonstrating the issue. The trouble is that your code is not minimal. Try to start removing parts of your setup that are irrelevant to the issue at hand. – Aditya Oct 31 '18 at 4:20
• OK, I will update my post. – ebohoyod Oct 31 '18 at 8:50
• I have just arrived home now, and no, I did not change the location parameter of \setuppagenumbering. – ebohoyod Oct 31 '18 at 20:40