\usemodule[mag-01]
% \input mathfix %Bugfix by Taco

\setuptyping[style=\ttx\setupinterlinespace]
\setupheadertexts[section]

\setupbodyfontenvironment	[default][em=italic]

\definetextbackground
  [example]
  [width=\textwidth,
   background=color,
   backgroundcolor=lightgray,
   frame=off,
   leftoffset=1em,
   rightoffset=1em,
   location=paragraph,
   after={\blank[small]},
   before={\blank[small]}]

\def\ShowExample
  {\startexample
%     \nobreak
    \typebuffer
   \stopexample
   \getbuffer}

\setvariables
  [magazine]
  [title={Using \textbackslash startalign and friends},
   author=Aditya Mahajan,
   date=\currentdate,
  ]


\starttext \setups[titlepage] \setups[title]
\startbuffer
\startformula \startalign[m=2]
  \NC a_1 x + b_1 y \NC = c_1 \NC d_1 u + e_1 v \NC = f_1 \NR
  \NC a_2 x + b_2 y \NC = c_2 \NC d_2 u + e_2 v \NC = f_2 \NR
\stopalign \stopformula
\stopbuffer
\ShowExample

The distance between the pairs can be increased by the option
\type<<distance>> of \tex{startalign}.
\startbuffer
\startformula \startalign[m=2,distance=5em]
  \NC a_1 x + b_1 y \NC = c_1 \NC d_1 u + e_1 v \NC = f_1 \NR
  \NC a_2 x + b_2 y \NC = c_2 \NC d_2 u + e_2 v \NC = f_2 \NR
\stopalign \stopformula
\stopbuffer
\ShowExample

A combination of \type<<[m=...,n=...]>> can be used.
\startbuffer
\startformula \startalign[m=2,distance=8em,n=5,
  align={right,middle,middle,middle,left}]
  \NC 0 \NC < \NC 2x + 5y \NC < \NC 10
  \NC 4 \NC < \NC 3x +  y \NC < \NC 9  \NR
  \NC 3 \NC < \NC 2y + 3z \NC < \NC 15
  \NC 10\NC < \NC 8y + 5z \NC < \NC 20 \NR
\stopalign \stopformula
\stopbuffer
\ShowExample

Sometimes, one simply wants to display two separate set of equations side by
side. For such applications the above pairs mode can be cumbersome to work
with.  There is another alternative in \tex{startformulas}

\startbuffer
\startformulas
  \startformula \startalign
    \NC a_1 x + b_1 y \NC = c_1 \NR
    \NC a_2 x + b_2 y \NC = c_2 \NR
  \stopalign \stopformula
  \startformula \startalign
    \NC d_1 u + e_1 v \NC = f_1 \NR
    \NC d_2 u + e_2 v \NC = f_2 \NR
  \stopalign \stopformula
\stopformulas
\stopbuffer
\ShowExample

More than two groups can also be placed.
\startbuffer
\startformulas
    \dorecurse{5}{\startformula
        \startalign[n=3,align={middle,middle,middle}]
            \NC a  \NC = \NC b  \NR
            \NC 2a \NC = \NC 2b \NR
        \stopalign
    \stopformula}
\stopformulas
\stopbuffer
\ShowExample


\stoptext
