Michael Gauland <mikely...@no8wireless.co.nz> writes: > I use R to plot data, and like to include information about the plot in the > caption. I do this by combining two named SRC blocks--one for the image, and > one > for the caption--and then put their #+RESULTS: together. The caption is the > tricky bit; I use R to print a string that starts with #+CAPTION:, shown in > the > exmaple below. While this works, I've wondered if there is a more elegant way > to > do this. How do others do this? > [snip]
For something simple like this, I'd use: ,---- | #+PROPERTY: session *R* | #+PROPERTY: results output | | #+NAME: image | #+HEADER: :results graphics | #+HEADER: :exports results | #+HEADER: :file (org-babel-temp-file "./figure-" ".pdf") | #+BEGIN_SRC R | x <- rnorm(100) | caption.string <- | sprintf("The mean value is %.3f.\n",mean(x)) | hist(x) | #+END_SRC | | | #+CAPTION: src_R[:results raw]{ cat(caption.string) } | #+RESULTS: image `---- For more complicated stuff I use ravel[1] to export as *.Rnw and then use knitr on the result. HTH, Chuck [1] see https://github.com/chasberry/orgmode-accessories/blob/master/ravel-org.md