2

Quite a while ago, I've created a word document where I defined variables, did calculations with them, and had the results printed inline into the document. Example output, where the result has been calculated from variables a = 1 and b = 2:

“The result of 1 plus 2 is 3”

For org-mode, I found that I can defined properties, and do basic calculations with them. But how do I output their values into running text, i.e. without using a table.

Naturally, I want the calculated value to be visible in the text buffer right in EMACS. If it’s only possible to see the value in an exported PDF, for example, then that’s not interesting.

7

You have to pick a language, and then src_<lang>{code}. For example,

src_octave{2+3}

When you evaluate that (with C-c C-c), you should see:

src_octave{2+3} {{{results(=5=)}}}

And 5 will be exported to PDF. If you want to use variables defined elsewhere, you can use the session option.

#+BEGIN_SRC octave :results output :session foo
a = 1;
b = 2;
#+END_SRC
#+RESULTS:

And then elsewhere:

src_octave[:session foo]{a+b} {{{results(=3=)}}}  

See http://orgmode.org/manual/Evaluating-code-blocks.html for more details.

  • Thanks, but I'd like to have the result inlined into text in the org mode buffer, without ugly code disrupting reading-flow. I normally don't use export. I use org-mode to write documents that are readable right in EMACS. – feklee Jul 2 '15 at 14:51
  • 1
    I would make this a non-Org question: how do I make text invisible between two tags, including tags. Ex: <hide> foo </hide>. Then put the inline code where it becomes invisible. This may be built into Org, for example using link syntax. I'd also try this on the mailing list where there are more eyes. – mankoff Jul 13 '15 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.