Difference between revisions of "\startcases"

From Wiki
Jump to navigation Jump to search
(New page: There are several built-in commands for displaying mathematical formulas. For instance <pre> \startcases, \stopcases \startmathmatrix, \stopmathmatrix \startalign,\stopalign </pre> Each h...)
 
m (Changed pre -> texcode)
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
There are several built-in commands for displaying mathematical formulas. For instance
 
There are several built-in commands for displaying mathematical formulas. For instance
  
<pre>
+
<texcode>
 
\startcases, \stopcases
 
\startcases, \stopcases
 
\startmathmatrix, \stopmathmatrix
 
\startmathmatrix, \stopmathmatrix
 
\startalign,\stopalign
 
\startalign,\stopalign
</pre>
+
</texcode>
Each has its own advantage and can be customized: for a thorough understanding of these commands please refer to Aditya Mohajan's excellent user's guide
+
Each has its own advantage and can be customized: for a thorough understanding of these commands please
[http://dl.contextgarden.net/myway/mathalign.pdf Using \startalign and friends]. These commands can be found in [[source:core-mat.tex|core-mat.tex]] file, which contains most of the core ConTeXt math macros.
+
refer to Aditya Mohajan's excellent user's guide  
 +
[http://dl.contextgarden.net/myway/mathalign.pdf Using \startalign and friends].  
 +
These commands can be found in [[source:core-mat.tex|core-mat.tex]] file, which contains  
 +
most of the core ConTeXt math macros.
 
   
 
   
<pre>
+
<context source="yes">
\starttext
 
 
 
 
This is an example of aligned equations:
 
This is an example of aligned equations:
 
\startformula
 
\startformula
Line 26: Line 27:
 
  \stopmatrix
 
  \stopmatrix
 
\stopformula
 
\stopformula
In these structures it is important to notice that the sign \type{=} is preceded by \type{\NC{}}, since  
+
</context>
 +
In these structures it is important (well, in the above example it is not important and the result is the same, but I have been told that it is necessary in some other situations...) to notice that the sign "=" is preceded by "\NC{}, since  
 
otherwise that sign would be considered as a binary operator and the alignment would be  
 
otherwise that sign would be considered as a binary operator and the alignment would be  
 
disturbed (at least this is what I guess…Otared K.).
 
disturbed (at least this is what I guess…Otared K.).
  
\stoptext
 
</pre>
 
 
One of the powerful structures in displaying mathematical formulas is the possibility of defining custom maths alignment.
 
One of the powerful structures in displaying mathematical formulas is the possibility of defining custom maths alignment.
 
For instance the following definition  
 
For instance the following definition  
  
<pre>
+
<texcode>
 
\definemathmatrix[alignedcases]
 
\definemathmatrix[alignedcases]
 
[align={right,left,left},
 
[align={right,left,left},
Line 42: Line 42:
 
right={\right.},
 
right={\right.},
 
style=\displaystyle]
 
style=\displaystyle]
</pre>
+
</texcode>
  
 
creates two new commands,  
 
creates two new commands,  
  
<pre>
+
<texcode>
 
\startalignedcases, \stopalignedcases:
 
\startalignedcases, \stopalignedcases:
</pre>
+
</texcode>
  
 
after which one may use them in a displayed formula as follows:
 
after which one may use them in a displayed formula as follows:
  
<pre>
+
<texcode>
\starttext
+
The following formula is displayed in two lines with an appropriate alignment of the equations:
 +
 
 +
\startformula
 +
\startalignedcases
 +
\NC -\Delta u + g(u) \NC{} = f \NC \quad\mbox{in } \Omega\NR
 +
\NC {\partial u \over \partial {\bf n} } \NC{} = h(u) \NC \quad\mbox{on } \partial\Omega  \NR
 +
\stopalignedcases
 +
\stopformula
 +
</texcode>
 +
 
 +
<context>
 +
\definemathmatrix[alignedcases]
 +
[align={right,left,left},
 +
distance=3pt,
 +
left={\left\{},
 +
right={\right.},
 +
style=\displaystyle]
  
 
The following formula is displayed in two lines with an appropriate alignment of the equations:
 
The following formula is displayed in two lines with an appropriate alignment of the equations:
Line 63: Line 79:
 
\stopalignedcases
 
\stopalignedcases
 
\stopformula
 
\stopformula
 
+
</context>
\stoptext
 
</pre>
 

Revision as of 22:17, 19 January 2009

There are several built-in commands for displaying mathematical formulas. For instance

\startcases, \stopcases
\startmathmatrix, \stopmathmatrix
\startalign,\stopalign

Each has its own advantage and can be customized: for a thorough understanding of these commands please refer to Aditya Mohajan's excellent user's guide Using \startalign and friends. These commands can be found in core-mat.tex file, which contains most of the core ConTeXt math macros.

This is an example of aligned equations:
\startformula
 \startcases[align={right,left},distance=3pt]
   \NC 2x + 3y \NC{} = 10 \NR
   \NC 3x + 2y \NC{} = 5,   \NR
 \stopcases
\stopformula
and this is another one:
\startformula
 \startmatrix[align={right,left},distance=3pt,left={\left\{}, right={\right.}]
   \NC 2x + 3y \NC{} = 10 \NR
   \NC 3x + 2y \NC{} = 5   \NR
 \stopmatrix
\stopformula

In these structures it is important (well, in the above example it is not important and the result is the same, but I have been told that it is necessary in some other situations...) to notice that the sign "=" is preceded by "\NC{}, since otherwise that sign would be considered as a binary operator and the alignment would be disturbed (at least this is what I guess…Otared K.).

One of the powerful structures in displaying mathematical formulas is the possibility of defining custom maths alignment. For instance the following definition

\definemathmatrix[alignedcases]
		[align={right,left,left},
		distance=3pt,
		left={\left\{},
		right={\right.},
		style=\displaystyle]

creates two new commands,

\startalignedcases, \stopalignedcases:

after which one may use them in a displayed formula as follows:

The following formula is displayed in two lines with an appropriate alignment of the equations:

\startformula
\startalignedcases
 \NC -\Delta u + g(u) \NC{} = f \NC \quad\mbox{in } \Omega\NR
 \NC {\partial u \over \partial {\bf n} } \NC{} = h(u) \NC \quad\mbox{on } \partial\Omega   \NR
\stopalignedcases
\stopformula