From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernt Hansen Subject: Re: Including row numbers in a table Date: Sat, 09 Aug 2008 02:57:48 -0400 Message-ID: <87r68yu13n.fsf@gollum.intra.norang.ca> References: <489D1FDB.2010603@gmail.com> <87vdyau3sm.fsf@gollum.intra.norang.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KRiOe-0003s1-IP for emacs-orgmode@gnu.org; Sat, 09 Aug 2008 02:57:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KRiOd-0003rF-VF for emacs-orgmode@gnu.org; Sat, 09 Aug 2008 02:57:51 -0400 Received: from [199.232.76.173] (port=57766 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KRiOd-0003r8-MJ for emacs-orgmode@gnu.org; Sat, 09 Aug 2008 02:57:51 -0400 Received: from mho-02-bos.mailhop.org ([63.208.196.179]:55586) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KRiOd-0007UM-9G for emacs-orgmode@gnu.org; Sat, 09 Aug 2008 02:57:51 -0400 In-Reply-To: <87vdyau3sm.fsf@gollum.intra.norang.ca> (Bernt Hansen's message of "Sat\, 09 Aug 2008 01\:59\:37 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Daniel J. Sinder" Cc: emacs-orgmode@gnu.org Bernt Hansen writes: > "Daniel J. Sinder" writes: > >> I'd like to use a formula for the first column so that if I move rows >> around using org commands, the row numbers can be easily >> re-calculated. Note that I'd like numbering to continue sequentially >> across horizontal lines. >> >> I've tried column formulas like @-1+1, but the horizontal lines get in >> the way. And if every row needs it's own formula, it's hardly better >> than just filling in the numbers. >> >> Can anyone suggest how to do this is a reasonably automated fashion? >> > > > | Row | Data Column 1 | Data Column 2 | > |-----+----------------+---------------------| > | 1 | some data | more data | > | 2 | some more data | even more data | > |-----+----------------+---------------------| > | 3 | and more | that's all | > | 4 | still more | yup, you guessed it | > |-----+----------------+---------------------| > #+TBLFM: $1=find(@I$2..@III$2,$2) > > This assumes the data in Data Column 1 ($2) is unique This works better. It doesn't assume anything about the data and you can add as many horizontal lines as you want in the table. This also removes the requirement for the trailing horizontal line from the previous solution. | Row | Data Column 1 | Data Column 2 | |-----+---------------+---------------| | 1 | x1 | | | 2 | some data | more data | |-----+---------------+---------------| | 3 | | | | 4 | | | | 5 | | | | 6 | | | #+TBLFM: $1=vlen(@I$2..0)/2;EN -Bernt