ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Maurice Diamantini <Maurice.Diamantini@ensta.fr>
Cc: Maurice Diamantini <Maurice.Diamantini@ensta.fr>
Subject: sample of using \startarray (long) was: Math startarray and \cases{xxx} bug?
Date: Tue, 17 May 2005 17:36:48 +0200	[thread overview]
Message-ID: <8A92F369-4013-45C9-B6EF-C1B0C6368979@ensta.fr> (raw)
In-Reply-To: <1A7D71A6-E93B-473E-9746-0D9D4455A850@ensta.fr>


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
%%%%%%%%%%%%%%%%%%%%%%

      reply	other threads:[~2005-05-17 15:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-13 14:16 Maurice Diamantini
2005-05-17 15:36 ` Maurice Diamantini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8A92F369-4013-45C9-B6EF-C1B0C6368979@ensta.fr \
    --to=maurice.diamantini@ensta.fr \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).