From mboxrd@z Thu Jan 1 00:00:00 1970 From: Erik Iverson Subject: Re: [babel] showing image of latex code results produced from an R code block Date: Fri, 14 May 2010 14:23:40 -0500 Message-ID: <4BEDA33C.8040502@ccbr.umn.edu> References: <4BEC78E8.8010106@ccbr.umn.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=50532 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OD0U6-0007Vg-U3 for emacs-orgmode@gnu.org; Fri, 14 May 2010 15:23:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OD0U4-0003FZ-Mr for emacs-orgmode@gnu.org; Fri, 14 May 2010 15:23:46 -0400 Received: from walleye.ccbr.umn.edu ([128.101.116.11]:4023) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OD0U4-0003FP-GZ for emacs-orgmode@gnu.org; Fri, 14 May 2010 15:23:44 -0400 Received: from tadpole.ccbr.umn.edu (tadpole.ccbr.umn.edu [128.101.116.26]) by walleye.ccbr.umn.edu (8.9.3p2/8.9.3) with ESMTP id OAA26489 for ; Fri, 14 May 2010 14:23:43 -0500 (CDT) Received: from iron.ccbr.umn.edu (iron.ccbr.umn.edu [128.101.116.194]) by tadpole.ccbr.umn.edu (8.9.3/8.9.3) with ESMTP id OAA25101 for ; Fri, 14 May 2010 14:23:41 -0500 (CDT) In-Reply-To: <4BEC78E8.8010106@ccbr.umn.edu> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode Solution below! Erik Iverson wrote: > Hello, consider the following org-mode file: > > ================================================= > > * R returning LaTeX for display > > I have an R function that generates LaTeX code. I would like the > resulting LaTeX to be displayed in an inline image in the org-buffer > > > #+begin_src R > lf <- function() { > "\\LaTeX" > } > > lf() > #+end_src > > #+results: > : \LaTeX > > I want the above results to actually be just like below, i.e., process > the results as LaTeX and include an image of the results. I think > org-babel can do this sort of thing, it's just escaping me how! > > * If I just specify LaTeX as the input language, all works as I hope > > #+begin_src latex :file latex-logo.png > \LaTeX > #+end_src[$] > > The LaTeX logo is displayed properly below on my screen with the latest > inline image functions. > > #+results: > [[file:latex-logo.png]] The solution is simply to give the R src block a name, then create a new src block of LaTeX code which calls the R src block using the noweb syntax. Note that in my actual application the LaTeX returned is *not* an R object like in my example, it is actually just text written to stdout, so in my R source block I use :results output. #+srcname: R-latex #+begin_src R lf <- function() { "\\LaTeX" } lf() #+end_src #+begin_src latex :noweb yes :file latex-logo.png <> #+end_src Now I can preview tables produced by Hmisc's latex function in my org-mode buffer, very nice!