emacs-orgmode
[Top][All Lists]
Advanced

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

[O] [babel] Variable support for ob-maxima


From: Thomas Holst
Subject: [O] [babel] Variable support for ob-maxima
Date: Wed, 23 Mar 2011 16:04:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (windows-nt)

Hello,

recent org-mode versions have support for maxima via org-babel. But
there is no support vor variables. I implemented basic support for
variables. A header =var: eq="x^2"= is translated to:

#+begin_src maxima
  eq : x^2;
#+end_src

I attached a patch to this eMail.

Now I can use the output from one maxima block and make a LaTeX equation
out of it with one maxima code block and reuse the output and make further
maipulations with it. I find it dificult to explain what I want to do,
so here is an example:

* Reuse Output of maxima code blocks

  #+source: eq1()
  #+begin_src maxima :exports none :results output verbatim
    display2d:false;
    eq1: x**2;
    print(eq1);
  #+end_src
  #+results: eq1
  : x^2 

  Pretty print equation with LaTeX:

  #+source: eq1-latex
  #+begin_src maxima :exports results :results output latex :var eq=eq1()
    print("\\begin{equation}");
    print(tex1(eq));
    print("\\end{equation}");
  #+end_src

  #+results: eq1-latex
  #+BEGIN_LaTeX
  \begin{equation} 
  x^2 
  \end{equation} 
  #+END_LaTeX

  Do some further calculation / maipulation to equation

  #+source: eq2()
  #+begin_src maxima :exports none :results output verbatim :var eq=eq1()
    display2d:false;
    eq2 : eq + sin(x);
    print(eq2);
  #+end_src
  #+results: eq5
  : sin(x)+x^2 

  Pretty print second equation:

  #+source: eq2-latex
  #+begin_src maxima :exports results :results output latex :var eq=eq2()
    print("\\begin{equation}");
    print(tex1(eq));
    print("\\end{equation}");
  #+end_src

  #+results:
  #+BEGIN_LaTeX
  \begin{equation} 
  \sin x+x^2 
  \end{equation} 
  #+END_LaTeX

With this workflow I have all org features for docmentation of math or
engineering works.

I am a lisp beginner so my lisp code may not be the best. If there are
better ways to accomplish variable support please let me know.

-- 
Best regards
  Thomas

Attachment: ob-maxima.el.patch
Description: Variable support for ob-maxima


reply via email to

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