So, is it possible not to apply \setuplayout
to part
and chapter
headers?
No, this is not possible. The settings in \setuplayout
determine the dimensions of the paper that the content will be printed on and since parts and chapters are going to be printed on the same paper as the rest of the document, it is illogical to have \setuplayout
somehow “ignore” them.
What you want to do is still possible* by setting the width
key in \setuphead
for the specified entries.
Using the default head alternative
The default headrendering will then adjust the size of the textblock to the specified width only for the heading.
* This is usually a sign that you were asking the wrong question.
\showgrid
\showframe
\setuplayout[topspace=10mm,
width=middle,
height=270mm,
header=10mm,
headerdistance=0pt,
footerdistance=0pt,
footer=0pt,
bottom=10mm,
bottomdistance=0pt,
cutspace=60mm,
rightmargin=50mm,
rightmargindistance=5mm]
\setuphead
[chapter]
[width=\dimexpr\makeupwidth+\rightmargindistance+\rightmarginwidth\relax]
\starttext
\startchapter[title={A very long chapter name just for the example}]
\samplefile{knuth}
\stopchapter
\stoptext

Using a custom head alternative
If you are using a different alternative
than the default normal
, then you will have to make it aware of the adapted width manually. In the comments you mentioned that you are using a custom alternative
based on this answer of mine. This is simple to adapt to the new requirements by setting \hsize
to \headwidth
inside the \vbox
that contains the heading. The dimension \headwidth
is set to the width
parameter that you supplied to \setuphead
within the headrendering code.
\showgrid
\showframe
\setuplayout[topspace=10mm,
width=middle,
height=270mm,
header=10mm,
headerdistance=0pt,
footerdistance=0pt,
footer=0pt,
bottom=10mm,
bottomdistance=0pt,
cutspace=60mm,
rightmargin=50mm,
rightmargindistance=5mm]
\defineheadalternative
[centered]
[alternative=vertical,
renderingsetup=headrenderings:centered]
\startsetups[headrenderings:centered]
\vbox {
\ifzeropt\headwidth\else
\hsize\headwidth
\fi
\headsetupspacing
\veryraggedcenter
\let\\\endgraf
\let\crlf\endgraf
\ifconditional\headshownumber
\strut
\headnumbercontent
%\par % <-- commented out
\else
\fakeheadnumbercontent
\fi
\begstrut
\headtextcontent
\endstrut
}
\stopsetups
\setuplabeltext[en][chapter=Chapter ]
\setuphead
[chapter]
[width=\dimexpr\makeupwidth+\rightmargindistance+\rightmarginwidth\relax,
commandbefore={:\,},
alternative=centered]
\starttext
\startchapter[title={A very long chapter name just for the example}]
\samplefile{knuth}
\stopchapter
\stoptext
