From mboxrd@z Thu Jan 1 00:00:00 1970 From: cberry@tajo.ucsd.edu Subject: Re: Generating captions--is there a better way? Date: Thu, 01 Nov 2012 22:43:03 -0700 Message-ID: <87mwz0ftlk.fsf@tajo.ucsd.edu> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUA2I-0006FX-VO for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 01:43:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUA2H-0006Qe-IG for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 01:43:18 -0400 Received: from plane.gmane.org ([80.91.229.3]:54439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUA2H-0006Qa-Be for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 01:43:17 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TUA2M-0005Pu-DG for emacs-orgmode@gnu.org; Fri, 02 Nov 2012 06:43:22 +0100 Received: from tajo.ucsd.edu ([137.110.122.165]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 02 Nov 2012 06:43:22 +0100 Received: from cberry by tajo.ucsd.edu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 02 Nov 2012 06:43:22 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Michael Gauland 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