One can add the following lines below unnamed source blocks (with bar
replaced by the intended table name):
#+NAME: bar
#+RESULTS:
||
The line with #+name: bar
is preserved after the evaluation of the source block and ||
is replaced with the resulting table.
Note, that the name bar
really names the table and not the source block.
That has the following consequences (probably among others I am not aware of at the moment):
If you refer to the table name in the header arguments of another source block, say buh
, then the bar
source block is not reevaluated when buh
is evaluated. The table is not updated but taken as argument for buh
as it is.
That is usually more an disadvantage than an advantage.
One can call org-babel-execute-buffer
to get correctly updated results.
If the source block returns a string containing the formatted org-table rather than table data referring to the source block name in header variables gets you the string and not the table data. That is most often unwanted.
In that case it is a big advantage that you can alternatively refer to the resulting table by its name.
If the source block is named, e.g., foo
replace #+RESULTS:
with #+RESULTS: foo
.
Example:
#+NAME: foo
#+BEGIN_SRC emacs-lisp :var alpha=2 :results value
(let* ((tol 0.1)
(alpha_1 (- 90 alpha)))
`(("angle" "symbol" "value" "max" "min") hline
("toe" "\\alpha" ,alpha ,(+ alpha tol) ,(- alpha tol))
("c" "\\alpha_1" ,alpha_1 ,(+ alpha_1 tol) ,(- alpha_1 tol))
))
#+END_SRC
#+TBLNAME: bar
#+RESULTS: foo
| angle | symbol | value | max | min |
|-------+----------+-------+------+------|
| toe | \alpha | 1 | 1.1 | 0.9 |
| c | \alpha_1 | 89 | 89.1 | 88.9 |
#+CALL: foo(alpha=bar[2,3])
#+NAME: buh
#+RESULTS:
| angle | symbol | value | max | min |
|-------+----------+-------+--------------------+-------------------|
| toe | \alpha | 1.1 | 1.2000000000000002 | 1.0 |
| c | \alpha_1 | 88.9 | 89.0 | 88.80000000000001 |
The example demonstrates the update problem. The header variable alpha
had the value 1 at the first evaluation of foo
. Afterwards the value was changed to 2 but the source block foo
was not evaluated again.
The evaluation of the #+CALL
statement does use the table value 1.1 at cell 2,3
directly without reevaluation of foo
.