[NTG-context] sample of using \startarray (long) was: Math startarray and \cases{xxx} bug?

Maurice Diamantini Maurice.Diamantini at ensta.fr
Tue May 17 17:36:48 CEST 2005


Le 13 mai 05 à 16:16, Maurice Diamantini a écrit :

> Bonjour à tous,
>
> I'm using amsl module, but it seems there is a probleme
> with the startarray/stoparray environment which apear with the "t"
> type of column (t for text) and the \\
> So the basic cases commande doesn't work.


Thanks to Otared Kavian, things are OK now ;-)

There are still pb with the behavior of \\ which should be replaced
with \cr, and (variants of) \startcases which are not consistents
with the cases{} tex command.
But here are some samples of way to use \startarray and some \cases{}

The few things I'll try to remember are:
- TeX is your friend (don't think in LaTeX)
   e.g.  \matrix command is is a core usefull command, \cr instead of  
\\, ...
- \startarray could be the more powerfull ConTeXt command about  
mathematiques
   can be (and is) use to build some other commands
- but this later command seems to not be embedable in another  
\startarray command
   and lacks of some documentations (exemples on how to ajust  
spaces, ...)

Also is there a mean (a wiki page?) where to start building a  
collection of
mathematics exemples using ConTeXt ?

- home to print the doc in newmat.tex ?

Cordialement,
-- Maurice Diamantini



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\enableregime[il1]
\useencoding[ffr]
\mainlanguage[fr]
\setuppapersize[A4]

\setuplayout[%
    topspace=1.0cm,
    backspace=2.0cm,
    % header=2.0cm,
    % footer=1.0cm,
    % margin=1.2cm,
    % margindistance=3mm,  % defaut = 5mm
    width=middle,
    height=middle%
]

\usemodule[amsl]
% \usemodule[nath]
\starttext

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Utilisation de startarray/stoparray (t-amsl.tex version 2004.11.18)
%
% DECONSELLE !
%  \startarray{xx...} ou { | x | x | ... |}
%    aaa & bbb & ccc \\
%    aaa & bbb & ccc \\
%    aaa & bbb & ccc
%  \stoparray
%
%  CONSEILLE
%  \startarray{xx...} ou { | x | x | ... |}
%    aaa & bbb & ccc \cr
%    aaa & bbb & ccc \cr
%    aaa & bbb & ccc \cr
%  \stoparray
%
% Le prÈambule {xxx...} :
% ----------------------
%     lrc = left, right, center
%     d => left avec \displaymath
%     t => left en texte (dans \text{...})
%     On peut compenser l'effet de l ou r par \hfil
%     ou inverser cet effet par \hfill
%
% Les variantes de cases utilisent un array prÈcÈdÈs d'une accolade
%
%   \startcases utilise  startarray{ll}
%   \startbigcases utilise  startarray{dl}
% mais
%   \cases{...} utilise  startarray{lt}
%
% BUG de array ?
%   le caractere t (text) semble ne pas fonctionner !
%   NON, mais il faut utiliser \cr au lieu de \\ en fin de ligne
%   et ne pas oublier le dernier \cp de la dernËre ligne !!
%

\section{Example of \type{\case} with or without \type{\displaystyle}}

\subsection{Without \type{\displaystyle}}
\startbuffer
\startformula
     {\bf f(x)} =
     \cases{
         \sum_{x=1}^n x  &       if I am true     \cr
         \sum_{x=1}^n y  & \quad if I am false    \cr
          0              & \quad if I don't know  \cr
    }
\stopformula
\stopbuffer
\getbuffer
\typebuffer

\subsection{With \type{\displaystyle}}
\startbuffer
\startformula
     {\bf f(x)} =
     \cases{
         \displaystyle
         \sum_{x=1}^n x   &       if I am true     \cr
         \displaystyle
         \sum_{x=1}^n y   & \quad if I am false    \cr
         \displaystyle
         0                & \quad if I don't know  \cr
    }
\stopformula
\stopbuffer
\getbuffer
\typebuffer

\page
\section{Example of \type{\startbigcases} with or without strut}
\subsection{Using \type{\startbigcases}}

Note the needed of \type{\text} as \type{\startbigcases} behavior
isn't the sames as \type{\cases}.

\startbuffer
\startformula
     {\bf f(x)} =
     \startbigcases
         \sum_{x=1}^n x   &  \quad\text{if I am true}    \cr
         \sum_{x=0}^n y   &  \quad\text{if I don't know} \cr
         0                &  \quad\text{if I am false}   \cr
     \stopbigcases
\stopformula
\stopbuffer
\getbuffer
\typebuffer

\subsection{Adding \type{\strut} to make the vertical spacing better}

Note the needed of \type{\text} as \type{\startbigcases} behavior
isn't the sames as \type{\cases}.

\startbuffer
\def\STR{\vrule height3.5ex depth1ex width0pt}
\startformula
     {\bf f(x)} =
     \startbigcases
         \sum_{x=1}^n x   &  if I am true                \cr
         \sum_{x=0}^n y   &  \quad\text{if I don't know} \cr
         \STR 0           &  \text{if I am false}        \cr
     \stopbigcases
\stopformula
\stopbuffer
\getbuffer
\typebuffer

\page
\section{Standard use of \type{\startarray}}
% \setuptyping[style=\small] % give bad results ! (no more typing font)
\startbuffer
\startformula
     {\bf e_u(t)} =
     \left\{
     \startarray{dllt}% ou bien : \startarray{| d | l | r | l}
             \sum_{x=1}^n f(x)
             & = ax^2 + b.x + c
             & = a
             &  \quad here some text
         \cr
             y^2 + z
             & = 3ax^3 + 3ax^2 + b.x + c
             & = \hfill b
             &
         \cr
             h(x)
             & = \hfil y_i
             & = a + b
             &  \quad encore du $(x^2)$ texte
         \cr
     \stoparray
     \right.
\stopformula
\stopbuffer
\getbuffer
\typebuffer

\page
\section{Combining arrays}

Array inside array doesn't seem to work. On should use \type{matrix}
from \TeX{} for this purpose.

\startbuffer
\def\TMPSTRUT{{\vrule height3ex depth2ex width0pt}}
\def\TMP{{
     \left|
       \matrix{
          \tx p_u(t)  \in {\cal P}_u       \hfill \cr
          \tx u       \in U                \hfill \cr
       }
     \right.%|
}}
\startformula
     {\bf e_u(t)} =
     \left\{
     \startarray{dllt}
             \sum_{\TMP}^n f(x)
             & = ax^2 + b.x + c
             & = a
             &  \quad here some text
         \cr\TMPSTRUT
             y^2 + z
             & = 3ax^3 + 3ax^2 + b.x + c
             & = \hfill b
             &
         \cr\TMPSTRUT
             h(x)
             & = \hfil y_i
             & = a + b
             &  \quad encore du $(x^2)$ texte
         \cr
     \stoparray
     \right.
\stopformula
\stopbuffer

\getbuffer
\typebuffer

\stoptext
%%%%%%%%%%%%%%%%%%%%%%



More information about the ntg-context mailing list