% interface=en output=pdftex
% $Id: brochure.tex,v 1.1 2005/10/20 19:33:25 michael Exp michael $

% Calculate the margin as a function of the number of columns and
% a percentage of the page width.
\def\numberofcolumns{3} % Number of columns.
\def\percentagewhitespace{5}% Margins are a proportion of the page width.
\def\margin{\dimexpr(\dimexpr(\paperwidth/\percentagewhitespace)/(\numberofcolumns * 2))}

% fake words
\usemodule[visual]
\setupsystem[random=1234]
\startbuffer
  \fakewords{10}{75}\par
  \fakewords{10}{50}\par
\stopbuffer

% Preliminaries
\setupcolors [state=start]
\setuppapersize[A4,landscape][A4,landscape]
\setuppagenumbering [state=off]

% Layout
\setuplayout
  [header=0pt, footer=0pt,
   width=middle, backspace=\margin]

% Stretched title texts
\def\CapStretchAmount{0.3em}
\def\CapStretch#1{\def\stretchedspaceamount{\CapStretchAmount}\stretchednormalcase{#1}}

% Subject title
\def\mysubject#1%
  {\framed [frame=off, offset=.5em,
            backgroundcolor=lightgray, background=color,
            width=broad]{\midaligned{\CapStretch{\sc #1}}}}
\setuphead [subject][textcommand=\mysubject]

% Columns
\definecolumnset
  [brochure]
  [n=\numberofcolumns,
   distance=2\backspace]

\starttext
  \count1=\numberofcolumns
  \multiply\count1 by 2
  \startcolumnset[brochure]
    \dorecurse {\count1} {
    \subject{Column \recurselevel}
      \getbuffer
    \column}
  \stopcolumnset
\stoptext

%finis
