Kierin Bell <bellkie...@gmail.com> writes: > When evaluating Babel code blocks with a ':results table' header > argument, what is the best way to automatically insert text _outside_ > of the table? > > For example, if I have a source block: > #+NAME: get-random-table > #+begin_src R :var length=12 :results table > runif(length) > #+end_src > > ... Then 'org-babel-execute-maybe' (C-c C-v e) will output a nicely > formatted Org table: > #+RESULTS: get-random-table > | 0.645291731692851 | > | 0.0425670417025685 | > | 0.220107783330604 | > | 0.413881630403921 | > | 0.817712268792093 | > | 0.972381719155237 | > > ... But if I want to insert a line, for example containing a 'NAME' > keyword, before and _outside of_ that table, there seems to be no easy > way to do this automatically.
Just insert it right before #+results keyword. #+results is just another affiliated keyword and can be combined with others. #+NAME: random-table-1 #+RESULTS: get-random-table | 0.645291731692851 | | 0.0425670417025685 | | 0.220107783330604 | | 0.413881630403921 | | 0.817712268792093 | | 0.972381719155237 | Also, if you use :exports results, you can refer to the table as "get-random-table" - the same with the source block name. > Trying to insert lines using subsequent code blocks (arguments, noweb, > etc.) will either strip Org table formatting or add additional lines > within the table instead of outside of it (depending on the ':results' > arguments). There is the same problem with using a ':post' header > argument, and ':wrap' does not allow arbitrary insertion of individual > lines. What is wrong with the example in 16.6 Results of Evaluation? It shows how to prepend #+ATTR_LATEX :width 5cm. #+NAME: would be the same. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>