ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
Subject: New math feature requests
Date: Tue, 8 Aug 2006 01:49:15 -0400 (EDT)	[thread overview]
Message-ID: <Pine.WNT.4.63.0608080147040.3232@nqvgln> (raw)

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

             reply	other threads:[~2006-08-08  5:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08  5:49 Aditya Mahajan [this message]
2006-08-08  5:59 ` Aditya Mahajan
2006-08-08  8:14   ` Hans Hagen
2006-08-08 14:20 ` Taco Hoekwater
2006-08-08 15:38   ` Aditya Mahajan
2006-08-25  1:34 ` Aditya Mahajan
2006-08-25  5:15 ` Aditya Mahajan
2006-08-26 16:37   ` Aditya Mahajan
2006-08-28 15:12     ` Wolfgang Schuster
2006-08-28 15:21       ` Hans Hagen
2006-08-28 17:10         ` Aditya Mahajan
2006-08-28 21:55           ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.WNT.4.63.0608080147040.3232@nqvgln \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).