mailing-list for TeXmacs Users

Text archives Help


Re: Improving eqnarray


Chronological Thread 
  • From: David Allouche <address@hidden>
  • To: address@hidden
  • Subject: Re: Improving eqnarray
  • Date: Wed, 20 Feb 2002 23:11:31 +0100

On Tuesday 19 February 2002 08:29, Adam Warner wrote:

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

Thanks. Actually I had to reverse engineer the source code to produce this
doc.

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

I think what you actually want is more along the lines of

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

Even if that do not make any essential difference, it is more robust and more
clean.


> 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}

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

You can also change the menu by just writing a $HOME/.TeXmacs/progs/Init.scm
file. But I admit that the current structure of TeXmacs menu definition makes
this a bit impractical.

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

If you do not want to have to make this change for every version of TeXmacs,
you should put it in a personal style file that you will use as a package:
"Document->use package->..."

Of course, if you do so, you will have to update the menu definition to show
the "5 column equations" item only when your package is available. I guess
the menu definition would look like:

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

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

I found a way to get this result using some little known table voodoo:
decorations. Essentially I use a table with 7 columns:

1 2 3 4 5 6 7
++---------------+----+-+----+---------------------------------------++
(x) y(x) = ax+b x\in{0,1}
++---------------+----+-+----+---------------------------------------++

The columns 1 and 7 (who contains the text at the end of lines) are forced to
width=0, while columns 2 and 6 are set to hpart (part of horizontal unused
part) of 1. As a consequence, columns 3,4,5 are centered and their position
is not affected by text in columns 1,6.

The trick is to make columns 2 and 6 be decorations of columns 1 and 7
(resp.) So they will not be editable.

<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|1|-1|cell bsep|0sep>|\
<cwith|1|-1|1|-1|cell tsep|0sep>|\
<cwith|1|-1|1|-1|cell lsep|0>|\
<cwith|1|-1|1|-1|cell rsep|0>|\
<cwith|1|-1|1|1|cell halign|l>|\
<cwith|1|-1|1|1|cell width|0>|\
<cwith|1|-1|1|1|cell decoration|<tformat|\
<cwith|1|1|2|2|cell hpart|1>|\
<table|<row|<tmarker>|<cell|>>>>>|\
<cwith|1|-1|-1|-1|cell halign|r>|\
<cwith|1|-1|-1|-1|cell width|0>|\
<cwith|1|-1|-1|-1|cell decoration|<tformat|\
<cwith|1|1|1|1|cell hpart|1>|\
<table|<row|<cell|>|<tmarker>>>>>|\
<cwith|1|-1|2|2|cell halign|r>|\
<cwith|1|-1|3|-3|cell halign|c>|\
<cwith|1|-1|-2|-2|cell halign|l>|\
<arg|body>>>>>>

--

-- David --




Archive powered by MHonArc 2.6.19.

Top of page