From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu Subject: Re: Weirdness re: inclusion of figures Date: Thu, 16 Feb 2012 13:59:20 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:38632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ry0wN-0005ez-6h for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 08:00:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ry0wC-0007kL-SY for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 08:00:02 -0500 Received: from mailout-de.gmx.net ([213.165.64.23]:33640) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Ry0wC-0007jt-Gn for emacs-orgmode@gnu.org; Thu, 16 Feb 2012 07:59:52 -0500 Received: by eaag11 with SMTP id g11so801421eaa.0 for ; Thu, 16 Feb 2012 04:59:50 -0800 (PST) In-Reply-To: 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: Paul Magwene Cc: emacs-orgmode@gnu.org Hello! The behaviour is actually as expected. To understand this, you have to consider, that org-mode currently only seems to recognize the relation between source block and #+result paragraph if one of these two conditions holds: o The "#+result:" line follows the source code without any text in betwee= n. o Both code block and "#+result:" line are labeled with the same name. Also consider, as said by Nick Dokos, the significance of the ":exports" header argument: o By default the result is computed but not exported. o If the (unnamed) result is delimited from the source code by intervening text, it is no longer considered any source blocks result: The exporter just ignores the "#+result:" line and includes the image into the exported file. Labelling a source code block can be done with a "#+NAME:" line preceding the code block. When evaluating the code block, the "#+results"-line automatically gets named too. When reevaluating a code block then the contents of this "#+results" entry is correctly refreshed even after intervening code. What you want thus probably is: : #+name: code-block : #+begin_src R :file z.png :results output graphics : plot(matrix(rnorm(100), ncol=3D2), type=3D"l") : #+end_src : : Intervening text : : #+results: code-block : [[file:z.png]] I did some tests to verify I'm right about this though, having installed a recent version from git (at most 2 days since the last pull): o No intervening text, no ":exports": Image is not exported. o No intervening text, ":exports both": Image is exported once; When exporting the code is rerun. o Intevening text, no ":exports": The image is exported once. The code block is not rerun on export. o Intervening text, ":exports both": The code is run twice (!), the image is exported both before and after the text. king regards, Yu 2012/2/16 Paul Magwene : > Hi All, > > I'm trying to get up to speed with org-mode and babel for doing > reproducible computational research. =C2=A0I'm just starting to play arou= nd > with simple examples, and I'm baffled by the following. > > This first example, when exported to HTML or LaTeX produces the > expected result -- a simply code block with one embedded figure. > > # Example 1. > > This is my R example: > > #+begin_src R :file z.png :results output graphics > plot(matrix(rnorm(100), ncol=3D2), type=3D"l") > #+end_src > > Some intervening text... > > #+results: > [[file:z.png]] > > > However, this almost identical example, minus the intervening text > between the code and the results, doesn't include the figure: > > # Example 2 > > This is my R example: > > #+begin_src R :file z.png :results output graphics > plot(matrix(rnorm(100), ncol=3D2), type=3D"l") > #+end_src > > #+results: > [[file:z.png]] > > > What gives here? Do I always need to have intervening text between the > source code and results in order to get a figure in the exported > document? > > Thanks, > Paul >