Open main menu

Changes

no edit summary
\stopitemize
</context>
 
 
= Sub-numbering of sub-Formulae with {{cmd|startsubformulas}} and {{cmd|startalign}} =
 
To use subformula numbering, you have to use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}} and {{cmd|startalign}}. For example
 
<context source="yes" text="This, when typeset, produces the following:">
The famous result (once more) is given by
 
Examples:
\definereferenceformat[eqref][left=(,right=)]
 
\startsubformulas[eq:total]
\placeformula
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq:second]
\stopalign
\stopformula
\stopsubformulas
 
Formula \eqref[eq:total] states the Pythagora's Theorem twice,
once in \eqref[eq:first] and again in \eqref[eq:second].
 
You can compare without \tex{startsubformulas}:
\placeformula
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq2:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq2:second]
\stopalign
\stopformula
 
We now have references for \eqref[eq2:first] and \eqref[eq2:second].
</context>
 
== The Manual Method ==
 
Sometimes, you need more fine grained control over numbering of subformulas. In that case one can make use of the optional agument of {{cmd|placeformula}} command and the related {{cmd|placesubformula}} commands which can be used to produce sub-formula numbering. For example:
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
Examples:
\placeformula{a}
\startformula
c^2 = a^2 + b^2
\stopformula
 
\placesubformula{b}
\startformula
c^2 = a^2 + b^2
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
Examples:
\placeformula{a}
\startformula
c^2 = a^2 + b^2
\stopformula
 
\placesubformula{b}
\startformula
c^2 = a^2 + b^2
\stopformula
</context>
</td></tr></table>
 
What's going on here is simpler than it might appear at first glance. Both {{cmd|placeformula}} and {{cmd|placesubformula}} produce equation numbers with the optional tag added at the end; the sole difference is that the former increments the equation number first, while the latter does not (and thus can be used for the second and subsequent formulas that use the same formula number but presumably have different tags).
 
This is sufficient for cases where the standard ConTeXt equation numbers suffice, and where only one equation number is needed per formula. However, there are many cases where this is insufficient, and {{cmd|placeformula}} defines {{cmd|formulanumber}} and {{cmd|subformulanumber}} commands, which provide hooks to allow the use of ConTeXt-managed formula numbers with plain TeX equation numbering. These, when used within a formula, simply return the formula number in properly formatted form, as can be seen in this simple example with plain TeX's {{cmd|eqno}}. Note that the optional tag is inherited from {{cmd|placeformula}}.
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
More examples:
\placeformula{c}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \eqno{\formulanumber}
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
More examples:
\placeformula{c}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \eqno{\formulanumber}
\stopformula
</context>
</td></tr></table>
 
In order for this to work properly, we need to turn off ConTeXt's automatic formula number placement; thus the {{cmd|let}} command to empty {{cmd|doplaceformulanumber}}, which must be placed <em>after</em> the start of the formula. In many practical examples, however, this is not necessary; ConTeXt redefines {{cmd|displaylines}} and {{cmd|eqalignno}} to do this automatically.
 
For more control over sub-formula numbering, {{cmd|formulanumber}} and {{cmd|subformulanumber}} have an optional argument parallel to that of {{cmd|placeformula}}, as demonstrated in this use of plain TeX's {{cmd|eqalignno}}, which places multiple equation numbers within one formula.
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
\placeformula
\startformula
\eqalignno{
c^2 &= a^2 + b^2 &\formulanumber{a} \cr
c &= \left(a^2 + b^2\right)^{\vfrac{1}{2}} &\subformulanumber{b}\cr
a^2 + b^2 &= c^2 &\subformulanumber{c} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
\placeformula
\startformula
\eqalignno{
c^2 &= a^2 + b^2 &\formulanumber{a} \cr
c &= \left(a^2 + b^2\right)^{\vfrac{1}{2}} &\subformulanumber{b}\cr
a^2 + b^2 &= c^2 &\subformulanumber{c} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</context>
</td></tr></table>
 
Note that both {{cmd|formulanumber}} and {{cmd|subformulanumber}} can be used within the same formula, and the formula number is incremented as expected. Also, if an optional argument is specified in both {{cmd|placefigure}} and {{cmd|formulanumber}}, the latter takes precedence.
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
More examples for left-located equation number:
\setupformulas[location=left]
\placeformula{d}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \leqno{\formulanumber}
\stopformula
and
\placeformula
\startformula
\leqalignno{c^2 &= a^2 + b^2 &\formulanumber{a} \cr
a^2 + b^2 &= c^2 &\subformulanumber{b} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
More examples for left-located equation no.:
\setupformulas[location=left]
\placeformula{d}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \leqno{\formulanumber}
\stopformula
and
\placeformula
\startformula
\leqalignno{c^2 &= a^2 + b^2 &\formulanumber{a} \cr
a^2 + b^2 &= c^2 &\subformulanumber{b} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</context>
</td></tr></table>
 
-- 23:46, 15 Aug 2005 (CEST) Prinse Wang
= Formating with {{cmd|setupformulas}} =
</context>
=Sub-Formula Numbering=
 
== Sub-Formulae numbering with {{cmd|startsubformulas}} and {{cmd|startalign}} ==
 
To use subformula numbering, you have to use {{cmd|startsubformulas}}/{{cmd|stopsubformulas}} and {{cmd|startalign}}. For example
 
 
<context source="yes" text="This, when typeset, produces the following:">
The famous result (once more) is given by
 
Examples:
\definereferenceformat[eqref][left=(,right=)]
 
\startsubformulas[eq:total]
\placeformula
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq:second]
\stopalign
\stopformula
\stopsubformulas
 
Formula \eqref[eq:total] states the Pythagora's Theorem twice,
once in \eqref[eq:first] and again in \eqref[eq:second].
 
You can compare without \tex{startsubformulas}:
\placeformula
\startformula
\startalign
\NC a^2 + b^2 \NC = c^2 \NR[eq2:first]
\NC a^2 + b^2 \NC = c^2 \NR[eq2:second]
\stopalign
\stopformula
 
We now have references for \eqref[eq2:first] and \eqref[eq2:second].
</context>
 
== The Manual Method ==
 
Sometimes, you need more fine grained control over numbering of subformulas. In that case one can make use of the optional agument of {{cmd|placeformula}} command and the related {{cmd|placesubformula}} commands which can be used to produce sub-formula numbering. For example:
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
Examples:
\placeformula{a}
\startformula
c^2 = a^2 + b^2
\stopformula
 
\placesubformula{b}
\startformula
c^2 = a^2 + b^2
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
Examples:
\placeformula{a}
\startformula
c^2 = a^2 + b^2
\stopformula
 
\placesubformula{b}
\startformula
c^2 = a^2 + b^2
\stopformula
</context>
</td></tr></table>
 
What's going on here is simpler than it might appear at first glance. Both {{cmd|placeformula}} and {{cmd|placesubformula}} produce equation numbers with the optional tag added at the end; the sole difference is that the former increments the equation number first, while the latter does not (and thus can be used for the second and subsequent formulas that use the same formula number but presumably have different tags).
 
This is sufficient for cases where the standard ConTeXt equation numbers suffice, and where only one equation number is needed per formula. However, there are many cases where this is insufficient, and {{cmd|placeformula}} defines {{cmd|formulanumber}} and {{cmd|subformulanumber}} commands, which provide hooks to allow the use of ConTeXt-managed formula numbers with plain TeX equation numbering. These, when used within a formula, simply return the formula number in properly formatted form, as can be seen in this simple example with plain TeX's {{cmd|eqno}}. Note that the optional tag is inherited from {{cmd|placeformula}}.
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
More examples:
\placeformula{c}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \eqno{\formulanumber}
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
More examples:
\placeformula{c}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \eqno{\formulanumber}
\stopformula
</context>
</td></tr></table>
 
In order for this to work properly, we need to turn off ConTeXt's automatic formula number placement; thus the {{cmd|let}} command to empty {{cmd|doplaceformulanumber}}, which must be placed <em>after</em> the start of the formula. In many practical examples, however, this is not necessary; ConTeXt redefines {{cmd|displaylines}} and {{cmd|eqalignno}} to do this automatically.
 
For more control over sub-formula numbering, {{cmd|formulanumber}} and {{cmd|subformulanumber}} have an optional argument parallel to that of {{cmd|placeformula}}, as demonstrated in this use of plain TeX's {{cmd|eqalignno}}, which places multiple equation numbers within one formula.
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
\placeformula
\startformula
\eqalignno{
c^2 &= a^2 + b^2 &\formulanumber{a} \cr
c &= \left(a^2 + b^2\right)^{\vfrac{1}{2}} &\subformulanumber{b}\cr
a^2 + b^2 &= c^2 &\subformulanumber{c} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
\placeformula
\startformula
\eqalignno{
c^2 &= a^2 + b^2 &\formulanumber{a} \cr
c &= \left(a^2 + b^2\right)^{\vfrac{1}{2}} &\subformulanumber{b}\cr
a^2 + b^2 &= c^2 &\subformulanumber{c} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</context>
</td></tr></table>
 
Note that both {{cmd|formulanumber}} and {{cmd|subformulanumber}} can be used within the same formula, and the formula number is incremented as expected. Also, if an optional argument is specified in both {{cmd|placefigure}} and {{cmd|formulanumber}}, the latter takes precedence.
 
<table width="100%" cols="2"><tr valign="top"><td width="50%">
<texcode>
More examples for left-located equation number:
\setupformulas[location=left]
\placeformula{d}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \leqno{\formulanumber}
\stopformula
and
\placeformula
\startformula
\leqalignno{c^2 &= a^2 + b^2 &\formulanumber{a} \cr
a^2 + b^2 &= c^2 &\subformulanumber{b} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</texcode>
</td><td>
<context>
\setuppapersize[A5]
\setuplayout[width=8cm]
More examples for left-located equation no.:
\setupformulas[location=left]
\placeformula{d}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2 \leqno{\formulanumber}
\stopformula
and
\placeformula
\startformula
\leqalignno{c^2 &= a^2 + b^2 &\formulanumber{a} \cr
a^2 + b^2 &= c^2 &\subformulanumber{b} \cr
d^2 &= e^2 &\formulanumber\cr}
\stopformula
</context>
</td></tr></table>
 
-- 23:46, 15 Aug 2005 (CEST) Prinse Wang
=List of Formulas=
1,005

edits