From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: org-export-sweave Date: Tue, 16 Sep 2008 14:41:55 +0200 Message-ID: <25FF1422-4BCE-4C55-B780-C8233ED9B4F7@uva.nl> References: Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KfZsf-0000eW-AK for emacs-orgmode@gnu.org; Tue, 16 Sep 2008 08:42:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KfZse-0000dC-7F for emacs-orgmode@gnu.org; Tue, 16 Sep 2008 08:42:08 -0400 Received: from [199.232.76.173] (port=46830 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfZse-0000cz-2R for emacs-orgmode@gnu.org; Tue, 16 Sep 2008 08:42:08 -0400 Received: from postduif.ic.uva.nl ([145.18.40.180]:35336) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KfZsd-0006du-1e for emacs-orgmode@gnu.org; Tue, 16 Sep 2008 08:42:07 -0400 In-Reply-To: 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: Austin Frank Cc: emacs-orgmode@gnu.org Hi Austin, since you want to include tis code literally into LaTeX, the best is probably to encapsulate it into #+BEGIN_LATEX .... #+END_LATEX and to try to solve only the local editing issue. Take a look at the function org-edit-src-find-region-and-lang. There is a list of regular expressions that can be used to identify regions that should be edited in special modes - maybe I can make this list extensible - first, give it a try and see if you can get it working by editing the list. - Carsten On Sep 1, 2008, at 3:19 PM, Austin Frank wrote: > Hello! > > Sweave is a preprocessing step that can be applied to LaTeX files that > contain code written in the S or R programming languages. Sweave > allows > authors to embed their statistical analyses in body of their LaTeX > articles, enabling what I find to be a very nice style of literate > programming. It seems to me like org currently has all of the > functionality needed to be a top-notch Sweave authoring environment, > but > I can't get the pieces to work correctly together. So this is both a > feature request and a request for implementation advice. > > I'm hoping that it will be possible to add an option for exporting > Sweave blocks from org mode. A Sweave block in LaTeX looks like > > % NB: options are comma separated, spaces are optional > \begin{Scode}{opt1=foo, opt2=bar,opt3=baz} > a <- 3 > a > \end{Scode} > > Right now I can easily get this exported using > > #+LATEX: \begin{Scode}{opt1=foo, opt2=bar,opt3=baz} > a <- 3 > a > #+LATEX: \end{Scode} > > But I would also like to be able to use the native editing mode for > writing the code, as happens in #+BEGIN_SRC blocks. I can't currently > get a combination of #+BEGIN_SRC and #+LATEX blocks to work. > > Would it be possible to have something like > > #+BEGIN_SWEAVE: language opt1=foo, opt2=bar, opt3=baz > a <- 3 > a > #+END_SWEAVE > > where the code inside the SWEAVE block is edited in the appropriate > major mode for the language argument? An actual use, then, would look > like > > #+BEGIN_SWEAVE: r fig=TRUE, echo=FALSE,keep.source=TRUE > x <- runif(100, 0, 100) > y <- runif(100, 0, 100) > plot(x ~ y) > #+END_SWEAVE > > C-c ' inside the block would call out to r-mode from the package ESS. > LaTeX export would result in > > \begin{Scode}{fig=TRUE, echo=FALSE,keep.source=TRUE} > x <- runif(100, 0, 100) > y <- runif(100, 0, 100) > plot(x ~ y) > \end{Scode} > > The file output by export to LaTeX should have the extension .Rtex. > The > author can then run Sweave on the file to generate a .tex file, and > then > the normal LaTeX compilation process continues. > > I've started trying to put this together myself, but haven't gotten > very > far. Some of the existing behavior for exporting source code relies > on > prefixing the code inside the block with a ':' at the beginning of the > line, which then results in a verbatim environment in LaTeX. I can't > figure out how to override this selectively for Sweave blocks, while > retaining the major-mode switching with C-c '. > > > Thanks for any implementations tips or (even better!) working > implementations ;) > > /au > > -- > Austin Frank > http://aufrank.net > GPG Public Key (D7398C2F): http://aufrank.net/personal.asc > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode