Org Extended has some support for org mode tables. True org tables support would allow for arbitrary emacs lisp to run as cell formulas within the table. Org Extended is not likely to build a lisp interpreter within sublime. I am less likely to support the full gamut of useful lisp functions.
That said, a lot can be done with basic calc support in sublime!
There are a number of things that make org tables super powerful:
- Org has a ton of power for editing and dynamically modifying tables, in plain text!
- Org supports a full computation engine built on emacs calc. We have a simplified version of that.
- Org tables can reference other tables. (Much like tabs in a spreadsheet)
- Org tables can act as inputs to babel really opening up your options for living documents. (we do not have this yet)
- Org tables can be the output of babel, again, really comming full circle on things. (we do not have this yet)
- Org can easily import csv files and other document types into your documents. (we have some support here)
That said, using the spreadsheet like capabilities of Org Extended will take a little effort on your part
Tab and Shift Tab are your friend. To start building a table, put a vertical bar symbol followed by some text and press tab. Voila, you have a table!
There is more. You can import a table or create a blank WxH table. But we will cover those later.
Next we need to extend our table. It is a pain to have to go over to the righthand side of the table to add a column. Org lets you insert a column almost anywhere!
Shift+Alt+Right Arrow --> Add a Col (pull it out, text grows to the right in english) Shift+Alt+Left Arrow --> Remove a Col (push it back)
The same works vertically!
Shift+Alt+Down Arrow --> Add a row (pull it out, tables grow down right!) Shift+Alt+Up Arrow --> Remove a row (push it back)
So now you realize that you laid out your table poorly and want to move the content around.
Alt+Right Arrow --> Move this row right Alt+Left Arrow --> Move this row left
The same works vertically!
Alt+Down Arrow --> Move this row down Alt+Up Arrow --> Move this row up
The cool thing you will see later is that org tries to preserve formula correctness as well when you move your cells around. But more on that in a sec.
Okay so now you have a table with some content that you hand authored. It’s time to start adding some smarts to your table!
First a quick demonstration. Org, like a spreadsheet can take a formula in a cell. Here is an example:
=vmean($2..$3) To regisster the formula you have to tell org about it, otherwise the formula is just text. Org stores the formula in a TBLFM comment at the bottom of the table. No exceptions that comment needs to be at the bottom of the table.
In this case we added a column formula. You can add a targetted formula by using:
:= - single cell formula = - column formula >= - row formula
You will notice org added some funny symbols to reference the target cell. We also used what looks like a range of cells. Org has a whole gamut of these, we support a subset.
Org use a row and column notation that has the following structure:
@ <ROW> $ <COL>
Some examples might include:
- ‘@2$3’
- 2nd row, 3rd column
- ‘$5’
- column 5 in the current row
- ‘@2’
- current column, row 2
- ‘@-1$-3’
- field one row up, three columns to the left
- ‘@>$5’
- field in the last row, in column 5
Range syntax is also supported:
- ‘$1..$3’
- first three fields in the current row
- ‘$<<<..$>>’
- start in third column, continue to the last but one
- ‘@2$1..@4$3’
- nine fields between these two fields
- ‘@-1$-2..@-1’
- 3 fields in the row above, starting from 2 columns on the left
OrgMode Table References Table Range References
To help with figuring out the indexes of your rows and columns Org Extended has a set of phantoms it can pop up to show you the layout of your table:
- Org Show Table Rows - Will show the layout of your table
- Org Hide Table Rows - Will hide the phantoms. These can be a little distracting so it helps to be able to turn them off
Once you have a few formulas you might want to re-evaluate all your formulas. You do this with the org Do What I Mean execute method:
Alt + o + c + c OR <space> c c
This will re-evaluate all references in the table.
Sometimes when doing a calculation it is a bit of a pain to work with a gamut of numbers and it helps to be able to assign a meaningful name. The CONSTANTS comment allows you to created named symbols that can be referenced from your tables:
#+CONSTANTS: pi=3.1415926 c=299792458
Note the lack of spaces and equal signs. These can now be referenced as symbols in your expressions:
=$1*$piSometimes, when planning or doing other operations you have stored some valuable data as properties in your document. You can access that data using property symbols:
=$1*$PROP_propnameThe $PROP_ prefix is added by the system to all properties in your document.
In addition, there are two special properties that can be used:
$# - Current column index of the document
@# - Current row index of the documentIn Emacs org mode formulas run inside calc. Calc has quite a few modes and control systems. For this reason you can append a semi colon to your formula and add control flags that control how calc operates when evaluating your expression. We do not have this situation. Our parser is OrgExtended specific and as such most of the control flags for calc are meaningless. That said, there are a couple of flags that are pretty useful:
- N - Adding this flag to a formula will treat all empty cells as a 0 value.
- %.#f - This lets you control the precision of floating point output. It is often visually disturbing to have many decimal places
in your output. With this you can limit the output to a smaller set of decimal places.
Here we are limiting our output to 3 decimal places:
| a | b | c | d | e | | 1 | 1 | | 1 | 1 | | 0.476 | 0.476 | 0.0 | 0.476 | 0.476 | #+TBLFM:@3=@2/2.1;N%.3f
Tables become even more useful when you can reference between tables! The remote function lets you do just that.
=remote('TableName',@2$3) #+NAME: TableName
| a | b | c | d |
| 1 | 2 | 3 | 4 |
Another table somewhere:
| a | b | c | d |
| | | >=remote('TableName',@2$3)*10 | |
Orgmode supports an advanced table mechanism. When using these features you need to put symbols in the first column of the table. These symbols are as follows.
OrgMode Advanced Table Features
- #
- Auto compute this row. When you use the table commands to move between cells these cells will be auto computed.
- *
- Non auto compute cell. Cells in this row will be included when recomputing the table (blank symbol will exclude a row from computation)
- $
- defines local table symbols in this row (max=5) that can be used in formulas.
- _
- name the cells below this row in this column. Cells can be referenced by name.
- ^
- name the cells above this row in this column. Cells can be referenced by name.
- !
- name all cells in this column. Cells can be referenced by this name.
a b c # 0.38 0.1 0.46 # 0.38 0.1 0.86 # 0.03 0.6 0.01 * 0.02 0.0 0.06 ^ hello world namedRow * 0.3 _ below # 3.5 0.7 # 4.5 0.9 # 4.0 0.8 # 2.0 0.4 $ max=5
No spreadsheet application would be complete without the ability to graph data. Emacs, and now we make that possible with GNU Plot.
To use it:
- install gnuplot
- Set your gnuplot path:
"gnuplot": "<fullpathtognuplot.exe>", - Run “Org Plot Table” with cursor on the table
#+PLOT: title:"Citas" ind:1 deps:(3 4) with:lines set:grid file:plot.png | Sede | Max | H-index | top | |-----------+--------+---------+-------| | Sao Paolo | 71.00 | 11.50 | 13.5 | | Stockholm | 134.19 | 14.33 | 16.33 | | Leeds | 165.77 | 19.68 | 21.68 | | Morelia | 257.56 | 17.67 | 19.67 | | Chile | 257.72 | 21.39 | 23.39 | #+TBLFM:$4=$3+2.0






