ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Math startarray and \cases{xxx} bug?
@ 2005-05-13 14:16 Maurice Diamantini
  2005-05-17 15:36 ` sample of using \startarray (long) was: " Maurice Diamantini
  0 siblings, 1 reply; 2+ messages in thread
From: Maurice Diamantini @ 2005-05-13 14:16 UTC (permalink / raw)
  Cc: Maurice Diamantini

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).
So the basic cases commande doesn't work.

Also the \startcases/stopcases should have the same meaning thas
\cases{xxx} has, but it doen't.

I use textlive distrib with a copy og t-amsl.tex version 2004.11.18

Thank you for any help!
-- Maurice Diamantini

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

\startformula
     {\bf f(x)} =
     \cases{
         \sum_{x=1}^n x      & if I am false
         \\
         \displaystyle% just to see the difference
         \sum_{x=1}^n x^2    & \text{if I am true}
    }
\stopformula

% This formala works as expected, but if I replace
% the forth column of type "l" which contains some \text{xxx} stuffs
% with a column of type "t" without using the \text command,
% there is an error.
\startformula
     {\bf e_u(t)} =
     \left\{
     \startarray{dlll}% ou bien : \startarray{| d | l | r | l}
         \displaystyle
         \sum_{x=1}^n f(x)
             & = ax^2 + b.x + c,
             & = a
             & \text{Here some text}
             \\
         \hfil y_2    % just to center stuff within a "d" column
             & = 3ax^3 + 3ax^2 + b.x + c,
             & = b
             &
             \\
         \sum_{x=1}^n h(x)
             & = y_2,
             & = a + b
             &  \text{encore du $(x^2)$ texte}
     \stoparray
     \right.
\stopformula

\startformula
     {\bf e_u(t)} =
     \startcases
         \sum_{x=1}^n f(x)
             & if I am true
         \\
         \displaystyle
         \sum_{x=1}^n h(x)
             & if I am false
     \stopcases
\stopformula
\stoptext

^ permalink raw reply	[flat|nested] 2+ messages in thread

* sample of using \startarray (long) was: Math startarray and \cases{xxx} bug?
  2005-05-13 14:16 Math startarray and \cases{xxx} bug? Maurice Diamantini
@ 2005-05-17 15:36 ` Maurice Diamantini
  0 siblings, 0 replies; 2+ messages in thread
From: Maurice Diamantini @ 2005-05-17 15:36 UTC (permalink / raw)
  Cc: Maurice Diamantini


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-17 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-13 14:16 Math startarray and \cases{xxx} bug? Maurice Diamantini
2005-05-17 15:36 ` sample of using \startarray (long) was: " Maurice Diamantini

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).