Background
The following screen shot shows four uneven columns, which is the desired result:
Problem
The beforesection and aftersection options to the setuphead command don't seem to have any effect, which results in the following:
Code
Reproduce the problem using:
\usemodule[newcolumnsets]
\definecolumnset[BookColumns][n=4]
\setupcolumnset[BookColumns:1][width=6in]
\setupcolumnset[BookColumns:2][width=4in]
\setupcolumnset[BookColumns:3][width=4in]
\setupcolumnset[BookColumns:4][width=4in]
\setuphead[chapter][
beforesection={\startcolumnset[BookColumns]},
aftersection={\stopcolumnset},
]
\definepapersize[BookPaperSize][
width=24in,
height=12in,
]
\setuppapersize[BookPaperSize]
\starttext
\chapter[title={Chapter Title}]
\dorecurse{5}{\input knuth \input lorem}
\stoptext
The uneven columns can be generated by changing the body to use \startcolumnset and \stopcolumnset directly:
\startcolumnset[BookColumns]
\chapter[title={Chapter Title}]
\dorecurse{5}{\input knuth \input lorem}
\stopcolumnset
Ideas
I tried redefining the chapter element as:
\let\oldchapter\chapter
\unexpanded\def\chapter{\dosingleempty\newchapter}
\def\chapter[#1]{\startcolumnset[BookColumns]\oldchapter[#1]\stopcolumnset}
This did not work. What does work is a series of sed calls:
sed -i 's/^\\chapter\(.*\)/\\stopcolumnset\n\\startcolumnset[BookColumns]\n\\chapter\1/' body.tex
sed -i '1d' body.tex
echo "\\stopcolumnset" >> body.tex
Calling sed is not the "ConTeXt way", of course.
A different question shows using beforesection and aftersection with mixedcolumns:
\setuphead[subsection][
beforesection={\startmixedcolumns[n=2,balance=no,]},
aftersection={\stopmixedcolumns},
page=no,
]
Question
How would you ensure that the \startcolumnset and \stopcolumnset commands bracket every chapter without modifying the body? (That is, apply column sets for each chapter only by changing the setups.)
Related
Related questions include:


beforesectionandaftersectionyou have to use\startchapterand\stopchapterinstead of\chapter. – Henri Menke Jul 20 '19 at 03:29\start...\stopsectionwith pandoc. I implemented this because you asked me to do it at some point: https://github.com/jgm/pandoc/pull/4295 – Henri Menke Jul 20 '19 at 03:40\setuplayout[grid=yes]for the new columnsets. Otherwise floats will be misplaced and column balancing breaks. – Henri Menke Jul 20 '19 at 03:48