How can I format a column of numbers in an emacs org mode table?
Here are the steps:
- This is an optional one, to make things a bit more visual.C-c } turns on the overlays for row and column numbers.Same combination turns the off. Note that these are not the changesin your buffer, they're just tooltips.You might want to do C-c - on the first line, to seethe column numbers.
- Move cursor to
OUTPUT
column and insert a new column with C-S-right. - Your cursor should now be in the new column.Type in
$4=$3;%0.3f
, i.e. copy the third column to the fourth,and format it as a floating point with 3 precision.Press return, and just one cell will fill in.Press C-u C-c * to recalculate all cells.This can also be done with C-c C-c, with cursoron#+TBLFM:
line. - You can remove the old column with C-M-left if you want,and delete the table formula below.
UPDATE:
Thanks to input from @phils, here's the alternative way:
- Move your cursor to any number in column 3, e.g.
433.275
. - Press C-c =, cursor moves to minibuffer.
- Enter
$0;%0.3f
and press return.Here$0
refers to the current column,$3
would also work if it were column 3. - Either press C-u C-c * anywhere in the document,or move the cursor to
#+TBLFM:
line and press C-c C-c. - Repeat the same process for column 4.