[NTG-context] New math feature requests
Aditya Mahajan
adityam at umich.edu
Tue Aug 8 07:49:15 CEST 2006
Hi Hans and Taco,
I am back with some more math request---one alignment construct, one
inner math alignment construct, and one formula tagging request. These
are primarily to "complete" the context math environments. I am
posting here rather than on the dev list, so that other math users can
also contribute. This is a loong mail.
1. Multiline equations (they are called multline equations in amsmath)
This is used to write multiline formulas (where alignement does not
make sense). The first line is left aligned, the last line is
rightaligned and all the middle lines are middle aligned.
The entire formula gets only one number. If the formulas are numbered
on the right, then the formula number is located on the last line; if
the formulas are numbered on the left, then the formula number is
located on the first line.
The alignment of a single line can be changed.
The first and the last line have a gap equal to \multlinegap from the
text border. If the formula is numbered, the gap is used only for the
line without the number.
I do not know what is a good syntax for this command. First of all, I
think we should call it multiline (rather than multline as in ams).
Then we can have
\placeformula
\startmultilineformula[gap=5pt]
\NC f(x) = ax \NR
\NC + bx + c + \NR
\NC e \NR
\stopformula
This should come out as (assuming formulas are numbered on the right)
5pt gap
|---f(x) = ax | <---- left aligned
| + bx + c + | <---- middle aligned
| + e (1) | <---- right aligned
If the formulas are numbered on the left
|(1) f(x) = ax |
| + bx + c + |
| + e---|
5pt gap
If there is no placeformula in the front then
|---f(x) = ax |<-- left aligned (5pt gap)
| + bx + c + |<-- middle aligned
| + e---|<-- right aligned with 5pt gap
If should be possible to get the 2nd line right aligned by using
\NC f(x) = ax \NR
\NC[align=right] + bx + c + \NR
\NC +e \NR
I am not sure of the syntax and the above \NC...\NR is just to
illustrate the point.
PS: I do not use multline of amsmath frequently. If someone does use
it, please read this carefully to ensure that I did not misread the
manual.
2. In amsmath, most of alignment constructs exist in two forms: outer
and inner. The mathalignment implemented in core-mat.tex corresponds
to outer alignment. The inner alignment is same as outer alignment,
but is only as wide as necessay. The most common amsmath inner
alignment constructs are aligned and gathered. It is easiest to
explain by means of an example. Suppose I want to type
a x + b y = c `\
} (simultaneous equations)
d x + e y = f /
,
I want to be able to do
\defineinnermathalignment[aligned][n=2,left={\left.},right={\right\}}]
\startformula
\startaligned
\NC ax + by \EQ c \NR
\NC dx + ey \EQ f \NR
\stopaligned
\quad \text{(simultaneous equations)}
\stopformula
One crude way to implement this is as follows
\def\startaligned{
%Whatever corresponds to left=
\left.
\framed[align=normal,frame=off,location=lohi]
% I do not know how to do this in terms of hboxes
\bgroup
\vskip-\baselineskip %There should be a better way
\startformula \startalign[n=2]}
\def\stopaligned{
\stopalign \stopformula
\egroup%end of framed
% Whatever correspons to right=
\right\}
}
\startformula
\startaligned
\NC ax + by \EQ c \NR
\NC dx + ey \EQ f \NR
\stopaligned
\quad \text{(simultaneous equations)}
\stopformula
I am sure that this definition can be improved. The innermath
environments should take three types of options
(n=...,m=....,distance=....,etc, that are passed to \startalign;
left=...,right=..., that put the left and right delimiters; and
location=high|low|lohi that align the innermath environment to the
baseline. Notice that the crude definition that I have given does not
handle location nicely.
I know Tex's limitation of scaling left and right delimiters on both
sides of the math centerline, making it difficult to handle left|right
and location correctly. It there is no easy fix, left|right can be
left out.
Such a construct will take care of aligned, gathered and split
environments of amsmath.
3. Formula tagging
amsmath allows formulas to be tagged. I will explain amsmath's
behaviour and hope that Hans can come up with the context way of doing
such things.
Occasionally, one wants to tag a formula, e.g.
\placefomrula[a] \startformula
a x = b
\stopformula
\placetaggedformula[b]{*} \startformula
x = \frac {b}{a}
\stopformula
should come out as
a x = b (1)
x = b/a (*)
Notice that ( and ) correspond to left and right in setupformulas. It
should also be possible to place a tag without these brackets, so
\placetaggedformulawithoutbrackets[c]{**} \startformula
b = ax
\stopformula
should come out as
b = ax ** <--- no brackets here
Maybe, instead of placetaggedformulawithout brackets, one can simply
have
\placetaggedformula[c][left=,right=]{**}
but in such cases it is easy to get confused with the reference and
options. I am not sure what is a good way to do this.
It should also be possible to refer to these tagged formulas. So
\in{formula}[b] should give * and \in{formula}[c] should give **.
The tag should be set in text mode, so that one can say
\placetagformula {Answer} and the Answer will come out in text mode.
Thanks,
Aditya
More information about the ntg-context
mailing list