ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Some proposed improvements for t-amsl.tex.
@ 2004-08-02 19:52 Brooks Moses
  0 siblings, 0 replies; 2+ messages in thread
From: Brooks Moses @ 2004-08-02 19:52 UTC (permalink / raw)
  Cc: Giuseppe Bilotta

Giuseppe and ConTeXt list members -

Having figured out how to use \grabuntil (see my previous messages to this 
list), I've realized that it's really an inconvenient solution in some 
cases, because it's searching for a literal bit of text rather than an end 
to the appropriate grouping level.  (Apparently there isn't a way to do the 
latter in TeX, given that AMSmath's \collect@body also searches for literal 
text.)  This means that, if I write a "LaTeX compatibility function" that 
does things like define \end{myenvironment} to expand to 
\stopmyenvironment, my redefinition will not work on any environments using 
\grabuntil.

This inconvenience happens to show up in t-amsl.tex's "align" and "gather" 
implementations, which is one place where I really need that compatibility 
function.  However, it turns out that there's a simple way to rewrite the 
implementation so to avoid needing \grabuntil.

Mostly, this works on the fact that the definition of Plain TeX's \eqalign 
function can be split apart into a before and after part, as follows:

\def\starteqalign{\null\,\vcenter\bgroup
   \openup\jot {\mathsurround=0pt}%
   \ialign\bgroup
       \strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
       \crcr}
\def\stopeqalign{\crcr\egroup\egroup\,}

(This, aside from the \bgroup's and \egroup's, is copied directly from 
Appendix B of The TeXbook.)  Thus, we could expand the instances of 
\eqalign in the \startalign and \startgather definitions, shuffle things 
around appropriately, and obtain the following:

\def\startalign{\startformula
    \let\\\cr
    \starteqalign}
\def\stopalign{\crcr\stopeqalign\stopformula}

\def\startgather{\startformula
    \def\\{\cr&}%
    \starteqalign&}
\def\stopgather{\crcr\stopeqalign\stopformula}

This exactly duplicates the existing functionality in the t-amsl.tex 
package.  However, that functionality could be improved to be a better 
match to what's provided in amsmath.tex; in particular, align should accept 
multiple columns of equations, and gather should center its lines.  Thus, I 
propose that the following redefinitions be included in t-amsl:

\def\startalign{\startformula
   \let\\\cr
   \null\vcenter\bgroup
   \openup\jot {\mathsurround=0pt}%
   \everycr={}\tabskip=4pt plus1fil \halign to \displaywidth\bgroup
       \strut\hfil$\displaystyle{##}$%
       \tabskip=0pt &$\displaystyle{{}##}$\hfil%
       \tabskip=4pt plus1fil &&\hfil$\displaystyle{##}$%
       \tabskip=0pt &$\displaystyle{{}##}$\hfil%
       \tabskip=4pt plus1fil \crcr}
\def\stopalign{\crcr\crcr\egroup\egroup\stopformula}

\def\startgather{\startformula
   \let\\\cr
   \null\,\vcenter\bgroup
   \openup\jot {\mathsurround=0pt}%
   \ialign\bgroup
       \strut\hfil$\displaystyle{##}$\hfil
       \crcr}
\def\stopgather{\crcr\crcr\egroup\egroup\,\stopformula}

Also, a similar method can be used to replicate the split environment 
(which, unlike the above, should go inside an explicit \startformula and 
\stopformula pair).  I propose the following definition be added as well:

\def\startsplit{%
   \let\\\cr
   \null\,\vcenter\bgroup
   \openup\jot {\mathsurround=0pt}%
   \ialign\bgroup
       \strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
       \crcr}
\def\stopsplit{\crcr\egroup\egroup\,}

This still doesn't address the fact that the lines in the align and gather 
environments are not given individual equation numbers as they should be, 
but I think that is a project for another day.

- Brooks


P.S. A question: is it intentional that the array environment in t-amsl 
produces notably different spacing than LaTeX's array environment?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Some proposed improvements for t-amsl.tex.
@ 2004-08-25 22:35 Giuseppe Bilotta
  0 siblings, 0 replies; 2+ messages in thread
From: Giuseppe Bilotta @ 2004-08-25 22:35 UTC (permalink / raw)


Hello Moses (uh ... I hope that's the name and Brooks is the
surname ... :)),

thank you very much for your email; it's very detailed and
useful, which is why I've only replied this late (well, also
because vacation-style RL popped in, but I digress :))

I'll address a couple of points replying under the relevant
text.

Monday, August 2, 2004 Brooks Moses wrote:

> This inconvenience happens to show up in t-amsl.tex's "align" and "gather"
> implementations, which is one place where I really need that compatibility
> function.  However, it turns out that there's a simple way to rewrite the
> implementation so to avoid needing \grabuntil.

> Mostly, this works on the fact that the definition of Plain TeX's \eqalign
> function can be split apart into a before and after part, as follows:

> \def\starteqalign{\null\,\vcenter\bgroup
>    \openup\jot {\mathsurround=0pt}%
>    \ialign\bgroup
>       
> \strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
>        \crcr}
> \def\stopeqalign{\crcr\egroup\egroup\,}

> (This, aside from the \bgroup's and \egroup's, is copied directly from
> Appendix B of The TeXbook.)  Thus, we could expand the instances of
> \eqalign in the \startalign and \startgather definitions, shuffle things
> around appropriately, and obtain the following:

> \def\startalign{\startformula
>     \let\\\cr
>     \starteqalign}
> \def\stopalign{\crcr\stopeqalign\stopformula}

> \def\startgather{\startformula
>     \def\\{\cr&}%
>     \starteqalign&}
> \def\stopgather{\crcr\stopeqalign\stopformula}

> This exactly duplicates the existing functionality in the t-amsl.tex
> package.

Stop #1. I *enormously* love this idea. Have you been running
test cases with this code instead of the one in t-amsl? If so,
then I'll put it in the official t-amsl instantly.

> However, that functionality could be improved to be a better
> match to what's provided in amsmath.tex; in particular, align should accept
> multiple columns of equations, and gather should center its lines.  Thus, I
> propose that the following redefinitions be included in t-amsl:

> \def\startalign{\startformula
>    \let\\\cr
>    \null\vcenter\bgroup
>    \openup\jot {\mathsurround=0pt}%
>    \everycr={}\tabskip=4pt plus1fil \halign to \displaywidth\bgroup
>        \strut\hfil$\displaystyle{##}$%
>        \tabskip=0pt &$\displaystyle{{}##}$\hfil%
>        \tabskip=4pt plus1fil &&\hfil$\displaystyle{##}$%
>        \tabskip=0pt &$\displaystyle{{}##}$\hfil%
>        \tabskip=4pt plus1fil \crcr}
> \def\stopalign{\crcr\crcr\egroup\egroup\stopformula}

> \def\startgather{\startformula
>    \let\\\cr
>    \null\,\vcenter\bgroup
>    \openup\jot {\mathsurround=0pt}%
>    \ialign\bgroup
>        \strut\hfil$\displaystyle{##}$\hfil
>        \crcr}
> \def\stopgather{\crcr\crcr\egroup\egroup\,\stopformula}

I like it. The only thing I would fix is that instead of the
fixed 0pt and 4pt I would set up some \dimens
(\intersomethingspacing or so). What do you think?

And again, if you have actually been using this code instead of
the one in t-amsl, I'll be happy to add it.

> Also, a similar method can be used to replicate the split environment
> (which, unlike the above, should go inside an explicit \startformula and
> \stopformula pair).  I propose the following definition be added as well:

> \def\startsplit{%
>    \let\\\cr
>    \null\,\vcenter\bgroup
>    \openup\jot {\mathsurround=0pt}%
>    \ialign\bgroup
>       
> \strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
>        \crcr}
> \def\stopsplit{\crcr\egroup\egroup\,}

> This still doesn't address the fact that the lines in the align and gather
> environments are not given individual equation numbers as they should be,
> but I think that is a project for another day.

Yeah, equation numbering in ConTeXt is something which I left
"for another day" myself (I need it for the nath package as
well).

> P.S. A question: is it intentional that the array environment in t-amsl
> produces notably different spacing than LaTeX's array environment?

No, it's simply due to the fact that I haven't even bother to
check if it were or not, because I didn't care either way :)
The parameters are there. We'd only have to check how to use it
within the ConTeXt spacing framework.

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-25 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-02 19:52 Some proposed improvements for t-amsl.tex Brooks Moses
2004-08-25 22:35 Giuseppe Bilotta

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).