<div dir="ltr"><div>Hello list, I'm trying to make something using bits and examples found here and elsewhere, but I'm hitting a wall. I know there's a flawed logic in my approach, but I can't figure it out. Any help is appreciated. <br></div><div><br></div><div>Expected behavior of the following MWE: <br></div><div>When starting a new chapter, check if the page is even (left page), if so, fill it with color, and start the chapter in the next odd page (right page), removing the header but leaving the footer in that start-chapter page; and if this is a start-chapter page, use a specific graphic overlay for the page, but if if not (if its a regular page), use another graphic. <br></div><div><br></div><div>Result: <br></div><div>The header still appears in the start-chapter page, if it comes after the color filled page. But, if the start-chapter page comes after a regular (even) page, everything works as expected (no color-filled page, no header in the start-chapter page). <br></div><div><br></div><div>MWE:<br></div><div><br></div><div>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% START MWE<br></div><div><br></div><div>\definecolor[rojo][h=ED553B]<br>\definehighlight[rojo][color=rojo]<br><br>\startMPinclusions<br>    numeric u ; u := 1.125pt ;<br>    numeric i ; i := 0.125in ;<br>    string prevChapterTitle, currentChapterTitle;<br>    prevChapterTitle := "";<br>    currentChapterTitle := "";<br>\stopMPinclusions<br><br>\startuseMPgraphic{page:background}<br>    StartPage;<br>        currentChapterTitle := "\namedstructurevariable{chapter}{title}";<br><br>        if currentChapterTitle <> prevChapterTitle :<br><br>            fill (topboundary Page -- cycle) <br>            enlarged(0,8i) <br>            shifted (0,-4i) <br>            withcolor transparent(4, 0.2, \MPcolor{rojo}) ;<br><br>            fill (bottomboundary Page -- cycle) <br>            enlarged(0,1u)<br>            shifted (0,6i) <br>            withcolor \MPcolor{rojo} ;<br>        <br>            prevChapterTitle := currentChapterTitle ;<br><br>        else: <br><br>            fill (topboundary Page -- cycle) <br>            enlarged(0,0.25u)<br>            shifted (0,-7i+3u) <br>            withcolor \MPcolor{rojo} ;<br>            <br>            fill (bottomboundary Page -- cycle) <br>            enlarged(0,0.25u)<br>            shifted (0,6i) <br>            withcolor \MPcolor{rojo} ;<br><br>        fi;<br>    StopPage;<br>\stopuseMPgraphic<br><br>\defineoverlay<br>  [chapter:background]<br>  [\useMPgraphic{page:background}]<br><br>\setupbackgrounds[page][background=chapter:background]<br><br>\definepagebreak[firstpagebreak][yes,header]<br><br>\startsetups [chapter:before]<br>   \doifoddpageelse<br>     {}<br>     {\pushbackground[page]<br>        \setupbackgrounds[page][background=color,backgroundcolor=rojo]<br>        \page[yes,right]<br>      \popbackground}<br>\stopsetups<br><br>\setuphead[chapter]<br>          [width=20em,<br>          before=\directsetup{chapter:before},<br>          align={flushleft,nothyphenated,verytolerant},<br>          style={\tfd\sansbold},<br>          header=empty,<br>          page=yes,<br>          commandbefore={\blank[1.75in]},<br>          after={\blackrule[color=rojo,height=4pt,width=6em]\blank[1.25in]}]<br><br><br>\setuppagenumbering[alternative=doublesided,location=]<br><br>\setupheadertexts<br>    []<br>    [{{\small\sans\getmarking[chapter]}}]<br>    [{{\small\sans\getmarking[chapter]}}]<br>    []<br><br>\setupfootertexts<br>    []<br>    [{\rojo{\small\sansbold\pagenumber}}]<br>    [{\rojo{\small\sansbold\pagenumber}}]<br>    []<br><br>\starttext<br><br>\dorecurse{4}{%<br>  \startchapter[title={A chapter with a really long, long title}]<br>  \dorecurse{9}{\input{tufte}}<br>  \stopchapter<br>  \startchapter[title={A different chapter with a really long, long title}]<br>  \dorecurse{6}{\input{tufte}}<br>  \stopchapter}<br><br>\stoptext</div><div><br></div><div>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% STOP MWE</div><div><br></div><div>Thank you for your time. <br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Andrés Conrado Montoya<br></div><br></div></div></div></div></div></div></div>