emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Generating captions--is there a better way?


From: cberry
Subject: Re: [O] Generating captions--is there a better way?
Date: Thu, 01 Nov 2012 22:43:03 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Michael Gauland <address@hidden> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]