Background
Creating a document that can have zero-, two-, or three-column layouts, depending on user preferences. I would like to keep the content clean of \columnsets by redefining only the sections (both section and chapter pages have independent styles).
For example, this produces the desired outcome, but requires duplicating the \startcolumnset for each \startsection, which I'd like to avoid:
\definecolumnset[StyleColumns][n=2,
%rule=on,
]
\startsection[title={Section1},reference=sec:section1,]
\startcolumnset[StyleColumns]
\placefigure[left]{}{%
\externalfigure[7b104cc5c6.jpg][width=\textwidth]}
This is a sentence that is really, really, really and very long.
\stopcolumnset
\stopsection
\startsection[title={Section2},reference=sec:section2,]
\startcolumnset[StyleColumns]
\placefigure[left]{}{%
\externalfigure[7b104cc5c6.jpg][width=\textwidth]}
This is a sentence that is really, really, really and very long.
\stopcolumnset
\stopsection
(The vertical rules don't work for me yet, but that's a separate issue.)
Problem
There are potentially hundreds of sections in the book that gets automatically generated. I would like to define whether or not multiple columns are used outside of the main content in a single location within the document (i.e., before the first \startbodymatter).
Forgiving my accent, I would like to do something such as:
% <CODE BLOCK>
\let\OldSection\section
\define\section{%
\startsection
\startcolumnset[StyleColumns]
\OldSection
\stopcolumnset
\stopsection
% </CODE BLOCK>
\startsection[title={Section1},reference=sec:section1,]
\placefigure[left]{}{%
\externalfigure[7b104cc5c6.jpg][width=\textwidth]}
This is a sentence that is really, really, really and very long.
\stopsection
\startsection[title={Section2},reference=sec:section2,]
\placefigure[left]{}{%
\externalfigure[7b104cc5c6.jpg][width=\textwidth]}
This is a sentence that is really, really, really and very long.
\stopsection
That way when the document is generated, if the <CODE BLOCK> is not included then the document won't use multiple columns.
Alternative Approach
I considered using conditional modes, but that would lead to either messy or duplicated content.
Question
How do you create a document using ConTeXt such that the \startsection...\stopsection code blocks can be made columnar without actually embedding \startcolumnset[X]...\stopcolumnset within each section's code block?
beforesectionis applied before the section heading, so strictly speaking the above is not equivalent to the OP. For that you would need to useafter={\startcolumnset[StyleColumns]}, aftersection=\stopcolumnset, which, I admit, is a bit weird – Aditya Aug 21 '13 at 18:48