emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Evaluating simple inline expressions in org-mode


From: Ken Mankoff
Subject: Re: [O] Evaluating simple inline expressions in org-mode
Date: Wed, 03 Feb 2016 08:58:25 -0500
User-agent: mu4e 0.9.16; emacs 24.5.1

On 2016-02-03 at 08:45, Gary Oberbrunner <address@hidden> wrote:
> I'd like to just have a few inline formulas evaluated in my org-mode
> document (I'm exporting to LaTeX if that matters). Something like this:
>
> =========================
> # a constant:
> # pi = 3.14159
>
> The value of interest is {{{2*$pi}}}.
> =========================
>
> I want that to export as:
>
>   The value of interest is 6.28318.

The following works for me:


#+BEGIN_SRC python :results output :exports none  :session foo
val = 2
#+END_SRC
#+RESULTS:

The value of interest is src_python[:session foo]{np.round(2*val,3)} 
{{{results(=4=)}}} and src_octave{2*pi} {{{results(=6.283185307179586=)}}}


You don't need the code block + session to set up a value for your example with 
pi, since Python and Octave know what pi is, but I demonstrate it here because 
you might want to work with something other than pi.

Python needs a [:session] to work for some reason on my system, but that is 
also beneficial so you can set up your variables. Note that your :session code 
block could take in an Org table as a header argument and define them in code 
from the table, so your actual variables are defined in an Org table, not in 
code. This is beginning to approach true literate programming...

  -k.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]