recently I am using table to do some statistics, and I want the first column of the table to indicate the row number, as this.

   |  | title|
   |--| -----|
   | 1| A    |
   | 2| B    |

and I want the number of first column grow automatically after creating a new row.

Are there good suggestions about it?

  • 23
    Place #+tblfm: $1=@#-1 under the table. Now when you move your mouse to the formula and C-c C-c on it, it will recalculate the contents of the first column s.a. to create a sequence of increasing integers. – wvxvw Aug 12 '15 at 8:51
  • wooo, great.... – Luis404 Aug 13 '15 at 1:39
  • 1
    I was looking for exactly the same thing (@#). Sometimes searching is faster than asking... ;-D – user543 Aug 13 '15 at 3:53
  • It's possible, but time-consuming, to figure this out from the manual by piecing together info from two sections (sometimes asking is faster than searching, reading, and thinking :) Go to the info-mode manual in emacs (C-h I), Section 3.5.1 of the manual, in an unnumbered sub-section called "Field coordinates in formulas," explains @#-1. Then section 3.5.6, "Column Fomulas," explains the $1=. – Reb.Cabin Jul 14 '19 at 17:50
  • 1
    Note that with @wvxvw's answer you can have 0-based indexing with $1=@#-2. – colelemonz Jan 2 at 18:12

Press S-ENTER in the first column after having put in '1' or another number and it will auto-increment in a new row. Not quite as clever as a formula, but is easier (for me) to remember.

| improve this answer | |
  • 2
    wvxvw's Aug 12 '15 answer is more generally powerful because it re-numbers all the rows if I insert a row someplace in the table, or if I cut and paste a group of rows. – Frank M Mar 20 '19 at 18:07
  • This is neat! Thanks. – tejasbubane Jan 4 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.