From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Mankoff Subject: Re: Evaluating simple inline expressions in org-mode Date: Wed, 03 Feb 2016 08:58:25 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQxwz-0005ne-AS for emacs-orgmode@gnu.org; Wed, 03 Feb 2016 08:58:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQxwy-0007yK-BK for emacs-orgmode@gnu.org; Wed, 03 Feb 2016 08:58:29 -0500 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:35631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQxwy-0007yC-7F for emacs-orgmode@gnu.org; Wed, 03 Feb 2016 08:58:28 -0500 Received: by mail-qk0-x232.google.com with SMTP id o6so8086422qkc.2 for ; Wed, 03 Feb 2016 05:58:27 -0800 (PST) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Gary Oberbrunner Cc: Orgmode Mailing List On 2016-02-03 at 08:45, Gary Oberbrunner 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.