\usemodule[mag-01]

\setuptyping[style=\ttx\setupinterlinespace]

\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
     \typebuffer
   \stopexample
   \getbuffer}

\starttext

Suppose you want to number only a few equations by a subformula and have 
normal formula numbering for others, it can be achieved by
\startbuffer
\def\CNR{\decrementnumber[formula]\NR} %Continued NR

\placeformula
\startformula \startalign
  \NC c^2 \NC = a^2 + b^2 \NR[+][a]
  \NC a^2 + b^2 \NC = c^2 \CNR[+][b]
  \NC d^2 \NC = e^2 \NR[+]
\stopalign \stopformula
\stopbuffer

\ShowExample

\section{Intertext}
Sometimes you want to place some text between two parts of math equations 
without disturbing equation alignment. \CONTEXT\ provides \tex{startintertext} 
environment to achieve this.

\startbuffer
\startformula \startalign
  \NC A_1 \NC= \left| \int_0^1 (x^2 - 3x)\, dx \right|
    + \left| \int_1^2 (x^2 -5x + 6)\, dx \right| \NR
  \startintertext
    Take limits of both integrals
  \stopintertext
  \NC \NC = \left| \frac{x^3}{3} - \frac{3}{2} x^2 \right|_0^1
    + \left| \frac {x ^3}{3} - 7 \frac{5}{2} x^2 + 6x \right|_1^2 \NR
    \NC \NC = \left| - \frac{7}{6} \right| + \left|\frac{14}{3} - 
    \frac{23}{6}\right| = \frac{7}{6} + \frac{5}{6} = 2 \NR
\stopalign \stopformula
\stopbuffer

\ShowExample


\section{Aligned Matrices}
\CONTEXT\ provides \tex{startmatrix} for generic alignment mechanism.
\startbuffer
\startformula
  \startmatrix
    \NC A \NC B \NC C \NR
    \NC a \NC b \NC c \NR
    \NC 1 \NC 2 \NC 3 \NR
  \stopmatrix
\stopformula
\stopbuffer
\ShowExample

\stoptext
