Difference between revisions of "Multiline equations"

From Wiki
Jump to navigation Jump to search
(→‎Alignment of each column: Added another example)
(Replaced content with "moved to Math/Multiline_equations")
Tag: Replaced
 
(65 intermediate revisions by 8 users not shown)
Line 1: Line 1:
== Basic Alignment ==
+
moved to [[Math/Multiline_equations]]
 
 
 
 
Two modes of input
 
 
 
* Latex style
 
<texcode>
 
\startformula \startalign
 
v &= u + at \\
 
h &= ut + \frac12 gt^2 \\
 
\stopalign \stopformula
 
</texcode>
 
 
 
Note the \\ in the last line, above.
 
 
 
This appears as follows:
 
 
 
<context>
 
\startformula \startalign
 
v &= u + at \\
 
h &= ut + \frac12 gt^2 \\
 
\stopalign \stopformula
 
</context>
 
 
 
* Context Style
 
 
 
<texcode>
 
\startformula \startalign
 
\NC v \NC = u + at \NR
 
\NC h \NC= ut + \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</texcode>
 
 
 
<context>
 
\startformula \startalign
 
\NC v \NC = u + at \NR
 
\NC h \NC = ut + \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</context>
 
 
 
(The examples here will focus on the context style, having two styles can be confusing --[[User:Adityam| Aditya ]] )
 
 
 
== Changing the number of columns ==
 
 
 
The above equations were aligned at <code>=</code>. Suppose you also want the <code>+</code> to align. Well, this is simple in context, simply specify the number of columns with <code>\startalign</code>
 
 
 
 
 
<texcode>
 
\startformula \startalign[n=3]
 
\NC v \NC = u \NC+ at \NR
 
\NC h \NC= ut \NC+ \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</texcode>
 
 
 
<context>
 
\startformula \startalign[n=3]
 
\NC v \NC = u \NC+ at \NR
 
\NC h \NC= ut \NC+ \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</context>
 
 
 
== Alignment of each column ==
 
If you want more control over the formatting, and want the middle column to be center aligned, you can do that by
 
<texcode>
 
\startformula \startalign[n=3,align={right,middle,left}]
 
\NC v \NC = u \NC+ at \NR
 
\NC h \NC= ut \NC+ \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</texcode>
 
 
 
<context>
 
\startformula \startalign[n=3,align={right,middle,left}]
 
\NC v \NC = u \NC+ at \NR
 
\NC h \NC= ut \NC+ \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</context>
 
 
 
This mechanism allows fancier alignments like
 
 
 
<texcode>
 
\startformula \startalign[n=4,align={left,right,middle,left}]
 
\NC \text{We have} \quad \NC v \NC = u \NC+ at \NR
 
\NC \text{and}          \NC h \NC= ut \NC+ \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</texcode>
 
 
 
 
 
<context>
 
\startformula \startalign[n=4,align={left,right,middle,left}]
 
\NC \text{We have} \quad \NC v \NC = u \NC+ at \NR
 
\NC \text{and}          \NC h \NC= ut \NC+ \frac12 gt^2 \NR
 
\stopalign \stopformula
 
</context>
 
 
 
== Working with equation numbering ==
 
 
 
== Changing the number of columns ==
 
 
 
== Cases ==
 
 
 
Context provides a <cmd>startmathcases</cmd> <cmd>stopmathcases</cmd> pair to make it easy get cases.
 
<texcode>
 
\startformula
 
f(x) = \startmathcases
 
  \NC x, \NC if $0 \le x \le \frac12$ \NR
 
  \NC 1-x ,\NC if $\frac12 \le x \le 1$ \NR
 
\stopmathcases
 
\stopformula
 
</texcode>
 
 
 
gives
 
 
 
<context>
 
\startformula
 
f(x) = \startmathcases
 
  \NC x, \NC if $0 \le x \le \frac12$ \NR
 
  \NC 1-x ,\NC if $\frac12 \le x \le 1$ \NR
 
\stopmathcases
 
\stopformula
 
</context>
 
 
 
The cases environment consists of two columns, separated by <cmd>NC</cmd>. The second column is by default in text mode. Each line must end with a <cmd>NR</cmd>.
 
 
 
== Numbered Cases ==
 

Latest revision as of 10:40, 12 May 2024