emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Charles Berry <ccberry@ucsd.edu>
To: emacs-orgmode@gnu.org
Subject: Re: inline Babel calls in math environments and table cells
Date: Wed, 13 Mar 2013 02:31:37 +0000 (UTC)	[thread overview]
Message-ID: <loom.20130313T031125-62@post.gmane.org> (raw)
In-Reply-To: CAFiLVradHDuv+U2hUJYMaW8-MSUd9kacX+YD4xDZuQiEcwpqkA@mail.gmail.com

Jay Kerns <gjkernsysu <at> gmail.com> writes:

> 
> Hello,
> 
> I went back and spent some time to rethink how I was approaching my
> problem.  Instead of inline src blocks like this:
> 
> \( SRC_R{blah} \)
> 
> or this
> 
> | SRC_R{blah} |

[deleted noweb stuff]

> This method works. I think it would be cool if it were possible to
> evaluate inline src blocks all over the place but on the other hand
> there are other tools which might be better suited for that kind of
> work. At least for the time being.  
> 


Jay,

It seems unlikely that inline src blocks will be allowed in table cells.

In org-element.el, there is this in org-element-object-restrictions - the 
alist of objects restrictions:

,----
|   ;; Ignore inline babel call and inline src block as formulas are
|   ;; possible.  Also ignore line breaks and statistics cookies.
|     (table-cell export-snippet footnote-reference latex-or-entity link macro
| 	  radio-target sub/superscript target text-markup timestamp)
`----
  

Another way to get where you want to go is to use the =brew= R package. The
markup is very simple - use <%= code %> in place of src_R{ code }.

Example:

,----
| #+DRAWERS: TABLEDRAWER
|
| * jay's query
|   :PROPERTIES:
|   :session:  *R:2*
|   :exports:  both
|   :END:
| 
| #+BEGIN_SRC R :results value
| A <- matrix(sample(100, size = 6), nrow = 2)
| #+END_SRC
| 
| #+RESULTS:
| | 51 | 77 | 63 |
| | 65 | 20 | 56 |
| 
| Put a table with brew markup in an example block in a drawer, so it
| will not appear in the output.
| 
| :TABLEDRAWER:
| #+NAME: src-blk-out
| #+BEGIN_EXAMPLE
| | a | b | <%= A[1,3] %> |
| | c | d | eeeee         |
| #+END_EXAMPLE
| :END:
| 
| Then use a call to ~brew()~ to run it. Note =:results output raw=
| #+NAME: test-src-blk-out 
| #+BEGIN_SRC R :results output raw :var tab=src-blk-out
| require(brew)
| brew(text=tab)
| #+END_SRC
`----

With point in or below the headline,

  C-c C-e C-s C-b l L 

exports the above as 

,----
| \begin{verbatim}
| A <- matrix(sample(100, size = 6), nrow = 2)
| \end{verbatim}
| 
| \begin{center}
| \begin{tabular}{rrr}
| 2 & 16 & 30\\
| 11 & 81 & 86\\
| \end{tabular}
| \end{center}
| 
| Put a table with brew markup in an example block in a drawer, so it
| will not appear in the output.
| 
| Then use a call to \verb~brew()~ to run it. Note \texttt{:results output raw}
| \label{test-src-blk-out}
| \begin{verbatim}
| require(brew)
| brew(text=tab)
| \end{verbatim}
| 
| \begin{center}
| \begin{tabular}{llr}
| a & b & 30\\
| c & d & eeeee\\
| \end{tabular}
| \end{center}
`----

  reply	other threads:[~2013-03-13  2:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 20:54 inline Babel calls in math environments and table cells Jay Kerns
2013-03-11 21:08 ` Jay Kerns
2013-03-11 21:26 ` Eric Schulte
2013-03-11 23:10   ` Jay Kerns
2013-03-12 15:35     ` Jay Kerns
2013-03-13  2:31       ` Charles Berry [this message]
2013-03-13  3:02         ` Jay Kerns

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=loom.20130313T031125-62@post.gmane.org \
    --to=ccberry@ucsd.edu \
    --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).