Pra*_*ani 19 emacs latex r org-mode sweave
当我使用Sweave时R,我可以通过简单地将绘图命令包含在代码块中来避免显式命名绘图文件<<fig=TRUE>> ... @.该Sweave驱动程序自动生成的编号打印文件一样fig1.pdf,fig2.pdf等等.
但是org-mode,似乎我需要:file [...].pdf在标题中使用a显式命名图形文件,例如
#+attr_latex: width=8cm placement=[htbp]
#+begin_src R :results output graphics :exports results :file fig.pdf                                                                                                                                                                                                 
    require(ggplot2)                                                                                                                           
    a <- rnorm(100)                                                                                                                            
    b <- 2*a + rnorm(100)                                                                                                                      
    d <- data.frame(a,b)                                                                                                                       
    ggplot(d,aes(a,b)) + geom_point()                                                                                                          
#+end_src                                     
有没有办法避免显式命名打印文件,并让org-mode latex导出引擎生成这些文件名?
更新:我提供了G. Jay Kerns在此处指出的解决方案,以便于参考:您需要做的就是在标题中包含生成临时文件的emacs-lisp函数,例如:file (org-babel-temp-file "./figure-" ".pdf").这会在当前目录中创建一个临时图形文件(因为./).如果你想在全局临时目录(由变量定义org-babel-temporary-directory)中使用临时图形文件,那么只需说".figure":
#+attr_latex: width=8cm placement=[htbp]
#+begin_src R :results output graphics :exports results :file (org-babel-temp-file "./figure-" ".pdf")                                                                                                                                                                                                 
    require(ggplot2)                                                                                                                           
    a <- rnorm(100)                                                                                                                            
    b <- 2*a + rnorm(100)                                                                                                                      
    d <- data.frame(a,b)                                                                                                                       
    ggplot(d,aes(a,b)) + geom_point()                                                                                                          
#+end_src