mailing-list for TeXmacs Users

Text archives Help


Re: combine cells/rows of a table?


Chronological Thread 
  • From: address@hidden
  • To: address@hidden
  • Subject: Re: combine cells/rows of a table?
  • Date: Sun, 9 Feb 2003 18:16:22 +0100

On Sun, Feb 02, 2003 at 07:42:46PM +0100, Marten Bauer wrote:
> Hello,
>
> i have written a gaussian elimation table for linear algebra an want to
> combine some table rows and columns. I read that i can do this with glueing
> them, but it didn't work right or I did it the wrong way.
> Could i also do it by defining a span?
>
> I have this table for example
>
> k | |
> ---|--------------------|------------------------------
> | 3 4 8 9 0 9 |
> | 7 2 3 9 3 0 | ....
> | 9 8 3 9 4 4 |
> | 0 3 9 0 9 9 |
> ---|--------------------|------------------------------
> ....
>
> Now I want to write a Formula above the matrix and a number on the left.
> How
> can i do this?

I am not sure I understand well what you want to do, but it seems to
me that glueing cells is not the right solution.

Glueing is a (quite obscure) feature which makes arbitrary cells
behave as border for other cells. For example that can be used to
emulate a "double-stroke" border style, or alignement on the decimal
point (by splitting the number in two cells and glueing a cell
containing a point with no border or padding).

If you want to use that feature, I recommand you also get acquainted
with the "disactivate table" and "set extension center" features,
because glued cells are not really easy to use and you should rather
now what you are doing if you want to get what you want.

But, for your gaussian elimination table, I think the right approach
is to use spanning cells and or subtable. An intelligent combination
of both can provide an layou which is robust when adding cells to the
table body.

(equation* (document
(tabular (tformat
(cwith "1" "-1" "2" "2" "cell lborder" "1ln")
(cwith "1" "-1" "2" "2" "cell rborder" "1ln")
(cwith "2" "2" "1" "-1" "cell tborder" "1ln")
(cwith "2" "2" "1" "-1" "cell bborder" "1ln")
(cwith "3" "3" "1" "1" "cell col span" "3")
(cwith "3" "3" "1" "1" "cell halign" "c")
(cwith "2" "2" "3" "3" "cell valign" "c")
(table
(row (cell "k") (cell "") (cell ""))
(row
(cell "")
(cell (sub_table (tformat
(cwith "1" "-1" "1" "-1" "cell halign" "c")
(table
(row (cell "3") (cell "4") (cell "8") (cell "9") (cell "0"))
(row (cell "7") (cell "2") (cell "3") (cell "9") (cell "3"))
(row (cell "9") (cell "8") (cell "3") (cell "9") (cell "4"))
(row (cell "0") (cell "3") (cell "9") (cell "0") (cell "9"))))))
(cell "12"))
(row (cell (with "mode" "text" "Some long formula"))
(cell "") (cell "")))))))

(copy and paste this in TeXmacs with [Edit->Paste from->Scheme])

Roughly... the first series of cwith sets the borders, says that
the first cell of the third row (your formula) will span three columns
(that is the entire table) and says how to align the number and
formula w.r.t. to the center cell.

The center cell is actually a subtable. That allows to add cells here
and still have the bottom cell span the entire table. You can get the
same layout by using a table in its own right (say, a tabular*) in the
center cell and by setting the padding of the enclosing cell to 0. I
believe subtables are meant to add some extra robustness to editing
(you cannot mistakenly type text in the enclosing cell).

The nice thing with TeXmacs is that you can do all of this (with
little extra garbage) solely using the GUI.

Now, if you are really a fearless hacker you can try to make a macro
from that. I just found however that TeXmacs will crash if your try to
extract the format of a subtable, so you will have to use the
nested-table approach. Still, it seems that TeXmacs is unable
recognize that a paramater of a multi-param macro is a table, (that
is, when this parameter is used in the macros within an extracted
table format).

--
David Allouche | GNU TeXmacs -- Writing is a pleasure
Free software engineer | http://www.texmacs.org
http://ddaa.net | http://alqua.com/tmresources
address@hidden | address@hidden
TeXmacs is NOT a LaTeX front-end and is unrelated to emacs.



Archive powered by MHonArc 2.6.19.

Top of page