Difference between revisions of "Talk:Math/Display"

From Wiki
Jump to navigation Jump to search
(Created page with "Removed old material. == The Manual Method == Sometimes, you need more fine grained control over numbering of subformulas. In that case one can make use of the optional agum...")
 
Line 1: Line 1:
 +
 +
== The Manual Method ==
 
Removed old material.
 
Removed old material.
  
== The Manual Method ==
+
-- 23:46, 15 Aug 2005 (CEST) Prinse Wang
  
 
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:
 
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:
Line 130: Line 132:
 
</context>
 
</context>
 
</td></tr></table>
 
</td></tr></table>
 
-- 23:46, 15 Aug 2005 (CEST) Prinse Wang
 

Revision as of 21:13, 11 May 2024

The Manual Method

Removed old material.

-- 23:46, 15 Aug 2005 (CEST) Prinse Wang

Sometimes, you need more fine grained control over numbering of subformulas. In that case one can make use of the optional agument of \placeformula command and the related \placesubformula commands which can be used to produce sub-formula numbering. For example:

Examples:
\placeformula{a}
\startformula
c^2 = a^2 + b^2
\stopformula

\placesubformula{b}
\startformula
c^2 = a^2 + b^2
\stopformula

What's going on here is simpler than it might appear at first glance. Both \placeformula and \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 \placeformula defines \formulanumber and \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 \eqno. Note that the optional tag is inherited from \placeformula.

More examples:
\placeformula{c}
\startformula
\let\doplaceformulanumber\empty
c^2 = a^2 + b^2   \eqno{\formulanumber}
\stopformula

In order for this to work properly, we need to turn off ConTeXt's automatic formula number placement; thus the \let command to empty \doplaceformulanumber, which must be placed after the start of the formula. In many practical examples, however, this is not necessary; ConTeXt redefines \displaylines and \eqalignno to do this automatically.

For more control over sub-formula numbering, \formulanumber and \subformulanumber have an optional argument parallel to that of \placeformula, as demonstrated in this use of plain TeX's \eqalignno, which places multiple equation numbers within one formula.

\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

Note that both \formulanumber and \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 \placefigure and \formulanumber, the latter takes precedence.

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