Li Bowen <a0050...@nus.edu.sg> wrote:

> Hi, 
> 
> If #+CAPTION is added, the figure will be included in the exported pdf
> file twice. 
> 
> #+begin_src R :exports both :results graphics :file img.pdf
> hist(rnorm(100))
> #+end_src
> 
> #+CAPTION: Some description
> #+RESULTS:
> [[file:img.pdf]
> 
> Many thanks.
> 

I think the problem is that the code block does not "see" the previously
produced #RESULTS: (because of the intervening #CAPTION:), so when run
again it adds another #RESULTS: section.

I think the best way to deal with problems like this is to name your code blocks
(and results blocks).

Try the following:

--8<---------------cut here---------------start------------->8---
#+name: foo
#+begin_src R :exports both :results graphics :file img.pdf
hist(rnorm(100))
#+end_src

#+CAPTION: Some description
#+RESULTS: foo
[[file:img.pdf]]
--8<---------------cut here---------------end--------------->8---

Does it solve the problem?

Nick

Reply via email to