Changes

Jump to navigation Jump to search
1,359 bytes removed ,  16:51, 20 June 2015
m
simplified context tags
* 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:
<contextsource=yes text="Note the \\ in the last line, above. This appears as follows:">
\startformula \startalign
v &= u + at \\
* Context Style
<texcode>\startformula \startalign \NC v \NC context source= u + at \NR \NC h \NC= ut + \frac12 gt^2 \NR\stopalign \stopformula</texcode> <contextyes>
\startformula \startalign
\NC v \NC = u + at \NR
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 \NCcontext source= ut \NC+ \frac12 gt^2 \NR\stopalign \stopformula</texcode> <contextyes>
\startformula \startalign[n=3]
\NC v \NC = u \NC+ at \NR
== 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>
<contextsource=yes>
\startformula \startalign[n=3,align={right,middle,left}]
\NC v \NC = u \NC+ at \NR
This mechanism allows fancier alignments like
<texcode>\startformula \startalign[ncontext source=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>  <contextyes>
\startformula \startalign[n=4,align={left,right,middle,left}]
\NC \text{We have} \quad \NC v \NC = u \NC+ at \NR
aligned equations can be numbered by placing a tag after {{cmd|NR}}
<texcode>\placeformula \startformula \startalign \NC v \NC context source= u + at \NR[eq:v] \NC h \NC = ut + \frac12 gt^2 \NR[eq:h]\stopalign \stopformulaEquation (\in[eq:v]) tells the final velocity after time $t$ and equation (\in[eq:h]) tells the distance travelled in time $t$.</texcode> <contextyes>
\setuplayout[scale=0.8,width=13cm]
\placeformula \startformula \startalign
New alignment can be defined using {{cmd|definemathalignment}}. For example, to emulate <code>gather</code> environment of amsmath, we can use
<texcode>
\definemathalignment
[gather]
[n=1,align={middle}]
 
\startformula \startgather
\NC ax^2 + bx + c = 0 \NR
\NC \text{roots} = \frac{ -b \pm \sqrt{b^2 - 4ac}}{2a} \NR
\stopgather \stopformula
</texcode>
<contextsource=yes>
\definemathalignment
[gather]
Context provides a {{cmd|startmathcases}} {{cmd|stopmathcases}} pair to make it easy to 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
<contextsource=yes text="gives">
\startformula
f(x) = \startmathcases
56

edits

Navigation menu