From: cberry@tajo.ucsd.edu
To: emacs-orgmode@gnu.org
Subject: Re: Generating captions--is there a better way?
Date: Thu, 01 Nov 2012 22:43:03 -0700 [thread overview]
Message-ID: <87mwz0ftlk.fsf@tajo.ucsd.edu> (raw)
In-Reply-To: loom.20121102T034842-341@post.gmane.org
Michael Gauland <mikelygee@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
prev parent reply other threads:[~2012-11-02 5:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-02 3:00 Generating captions--is there a better way? Michael Gauland
2012-11-02 5:43 ` cberry [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwz0ftlk.fsf@tajo.ucsd.edu \
--to=cberry@tajo.ucsd.edu \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).