mailing-list for TeXmacs Users

Text archives Help


Improving eqnarray


Chronological Thread 
  • From: Adam Warner <address@hidden>
  • To: address@hidden
  • Subject: Improving eqnarray
  • Date: 19 Feb 2002 20:29:53 +1300

On Mon, 2002-02-18 at 18:05, Phil Mendelsohn wrote:
> On Mon, Feb 18, 2002 at 04:52:16PM +1300, Adam Warner wrote:
> > So the formatting looks like this:
> >
> > y=a*(b+c)
> > =ab+ac
> >
> > One way to approximate this is to use a table which leads to the
> > formatting looking something like this:
> >
> > y = a*(b+c)
> > = ab+ac
> >
> > but the spacing between the = sign is too large.
>
> Using Insert > Math > Equation_s_ (note the 's') will give you what
> you want. Type the first part of your eqn, then CTRL-f, for the
> middle column of what's analogous to LaTeX's {eqnarray} environment,
> then CTRL-f again when you want the third column.

Unfortunately eqnarray is like using a plain table. Specifically it
leaves too much space between the LHS and RHS of the equation and the =
sign (middle operator). This looks out of place when a standard equation
has no such extra spacing. This is for example recognised by some who
use AMS-LaTeX <http://www.stat.umn.edu/~charlie/amslatex.html>: "Spacing
around equals signs matches the normal spacing in the equation
environment (unlike eqnarray)".

So I set about editing eqnarray in basic.ts to eliminate this extra
spacing (trial and error at first and then I found this critical piece
of information: http://alqua.com/tmresources/internal%20table%20markup).
The result is an equation with spacing that looks very similar to a
standard non-tabular equation. This is the original piece of
<assign|eqnarray*>:

<cwith|1|-1|1|1|cell lsep|0spc>|<cwith|1|-1|-1|-1|cell rsep|0spc>

And this is the replacement:

<cwith|1|-1|2|2|cell lsep|-0.15fn>|<cwith|1|-1|2|2|cell rsep|-0.15fn>

What this does is reduce the left and right margins around the second
(centre) cell by -0.15fn.

After this change you will not see the difference between a one line
equation and a one line eqnarray.


The second improvement is a new equation definition by allowing LHS
and/or RHS pieces of mathematics on the same line:

Columns:
1 2 3 4 5
(x) y(x)=a+bx x\in{0,1}

This new macro definition achieves this:

<assign|fivecoleqnarray*|<macro|body|<with|paragraph
mode|center|mode|math|formula
style|true|<surround|<format|no page break
before><vspace*|0.5fn>|<vspace|0.5fn><format|no indentation
after>|<tformat|<twith|table hyphen|y>|<twith|table
width|1par>|<twith|table min cols|5>|<twith|table max
cols|5>|<cwith|1|-1|3|3|cell lsep|-0.15fn>|<cwith|1|-1|3|3|cell
rsep|-0.15fn>|<cwith|1|-1|1|-1|cell bsep|0sep>|<cwith|1|-1|1|-1|cell
tsep|0sep>|<cwith|1|-1|1|1|cell hpart|1>|<cwith|1|-1|-1|-1|cell
hpart|1>|<cwith|1|-1|1|1|cell halign|l>|<cwith|1|-1|2|2|cell
halign|r>|<cwith|1|-1|1|1|cell
hyphen|b>|<cwith|1|-1|3|-3|cell halign|c>|<cwith|1|-1|-2|-2|cell
halign|l>|<cwith|1|-1|-1|-1|cell halign|r>|<cwith|1|-1|-1|-1|cell
hyphen|t>|<arg|body>>>>>>

You can add it to the TeXmacs menu by adding a line to main-menu.scm:

(-> "mathematics"
("formula" "$" (make-with "mode" "math"))
(if (style-has? "basic-style")
("equation" (make-big-expand "equation*"))
("equations" (make-expand-arg "eqnarray*"))
("5 column equations" (make-expand-arg "fivecoleqnarray*"))
("numbered equation" (make-big-expand "equation"))))

Then put the replacement basic.ts into the appropriate folder and
recompile the program (./configure && make and make install as root).

To improve the centring of columns 2,3,4 I'd like to be able to
automatically set the width of columns 1 and 5 equal to the width of the
widest column. This should stop the entering of column 1 or column 5
maths moving the 2,3,4 cells to the right or left respectively. If
someone could give me some pointers how to achive this I'd appreciate
it.

It would work like this:

Columns:
1 2 3 4 5
y(x)=a+bx 1234567890

\___ ___/ \___ ___/
\/ \/
Width of column 1: 0 Width of column 5: 10
Width col 1 < width col 5
Thus set width of column 1 to 10

(and vice versa if column 1 is wider than column 5)

Regards,
Adam





Archive powered by MHonArc 2.6.19.

Top of page