ConTeXt: Columnar section titles, floats, and images

Here I present a solution which uses the second optional argument of the sectioning commands.

The values can be retrieved with the command \structureuservariable. First, a custom head alternative is defined which checks if the figure key is present. If it is, it includes the figure and the section head, otherwise only the section head is included. Then the section head is set up to use the custom head alternative.

\setupexternalfigures
  [location=default]

\defineframed
  [headframe]
  [width=\textwidth,
   frame=off]

\defineheadalternative
  [graphiccolumn]
  [renderingsetup=graphiccolumn]

\startsetups [graphiccolumn]
  \headsetupspacing
  \doifsomethingelse
    {\structureuservariable{figure}}
    {\headframe
      {\externalfigure[\structureuservariable{figure}]\hfill
       \headnumbercontent\space\headtextcontent}}
    {\headnumbercontent\space\headtextcontent}
\stopsetups

\setuphead
  [section]
  [alternative=graphiccolumn]

\starttext
  \startsection [title=Alpha] [figure=cow]
    \input ward
  \stopsection

  \startsection [title=Beta]
    \input ward
  \stopsection

  \startsection [title=Gamma] [figure=hacker]
    \input ward
  \stopsection
\stoptext

result


Creating a custom section to indicate when a photograph is present (sectionpicture) allows for that section to be wrapped in a two-column mode and its title made empty. This preserves the structure of the document allowing for a wide variety of layout possibilities.

It might also be possible to use:

\def\trueref{true}
\startsection[title=Section One][picture=\trueref]
  \Photograph
  % ...
\stopsection

However, I could not get that approach to work. Instead, the code following the preview almost produces the correct result.

Preview:

Result

Code:

\setuppapersize[letter][letter]
\setuplayout[width=fit,]
\setupalign[hz,tolerant,]

\setuphead[chapter,section,subsection][header=none,number=no,]

\setuphead[chapter][footer=empty,after=\page,]
\setuphead[section][page=yes,]

\setuphead[subsection][
  before={\vskip0.5em},
  after={\vskip0.5em},
  page=no,
]

\setuphead[subsection][
  beforesection={\startmixedcolumns[n=2,balance=no,]},
  aftersection={\stopmixedcolumns},
  page=no,
]

\definehead[sectionpicture][section][
  placehead=empty,
  before={\startcolumns[n=2,]},
  after={\vskip-1em},
]

\defineitemgroup[Preparation]
\setupitemgroup[Preparation][each][packed][
  before={\empty},
]

\setupexternalfigures[
  width=\hsize,
  location={none,left,high},
]

\definenamespace[Photograph][
  type=module,
  name=Photograph,
  parent=Photograph,
  setup=list,
  version=1.0,
  style=yes,
  command=list,
]

% Define parameters within the Photograph namespace.
\setupPhotograph[
  author=,
  homepage=,
  source=,
  % Pass along the current section title into the Photograph macro.
  sectiontitle={\namedstructurevariable{section}{title}},
  attribution=photo:,
  cite={%
    \Word{\Photographparameter{attribution}} %
    \Photographparameter{author}},
]

\setupcaptions[location=,]
\definefloat[photograph][photographs][figure]

\showframe

% Defines how the photograph is used.
\def\Photograph{%
  \placephotograph[top,left,force]{}{\externalfigure[fake][]}
  \columnbreak
  {\switchtobodyfont[24pt]\Photographparameter{sectiontitle}} \par \\
  \Photographparameter{cite}
  \stopcolumns
}

\starttext
  \startchapter[title=Chapter One]
    \startsectionpicture[title=Section One]
      \Photograph

      \startsubsection[title=Subsection]
      \input douglas
      \stopsubsection

      \startsubsection[title=Preparation]
      \startPreparation
      \dorecurse{3} { \startitem Pour liquid helium into flask. \stopitem }
      \stopPreparation
      \stopsubsection
    \stopsectionpicture

    \startsection[title=Section Two]
      \startsubsection[title=Subsection]
      \input knuth
      \stopsubsection

      \startsubsection[title=Preparation]
      \startPreparation
      \dorecurse{3} { \startitem Pour CO$_2$ into beaker. \stopitem }
      \stopPreparation
      \stopsubsection
    \stopsection
  \stopchapter
\stoptext