emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Austin Frank <austin.frank@gmail.com>
To: emacs-orgmode@gnu.org
Subject: org-export-sweave
Date: Mon, 01 Sep 2008 09:19:03 -0400	[thread overview]
Message-ID: <m0abesf1h4.fsf@gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2664 bytes --]

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

[-- Attachment #1.2: Type: application/pgp-signature, Size: 193 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
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

             reply	other threads:[~2008-09-01 13:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01 13:19 Austin Frank [this message]
2008-09-16 12:41 ` org-export-sweave Carsten Dominik
2008-09-17 18:44   ` org-export-sweave Austin Frank
2008-09-18  8:58     ` org-export-sweave Carsten Dominik
2008-09-22 22:18       ` org-export-sweave Austin Frank
2008-09-23  6:14         ` org-export-sweave Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m0abesf1h4.fsf@gmail.com \
    --to=austin.frank@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).