|
From: | Federico Beffa |
Subject: | Re: [O] latex equations and $ sign |
Date: | Wed, 9 Jul 2014 15:31:18 +0200 |
Is there a reason you are not using a mode argument like this:Federico Beffa <address@hidden> writes:
> Hi,
>
> I would like to have a mathematical equation typeset in latex and
> automatically generated by sympy, embedded in an equation environment:
>
> #+NAME: mass-energy
> #+BEGIN_SRC python :results raw :exports results :wrap EQUATION
> import sympy as sp
> E, m, c = sp.symbols('E, m, c', real=True, positive=True)
> E = m*c**2
> return sp.latex(E)
> #+END_SRC
>
>
> #+NAME: eq:1
> #+RESULTS: mass-energy
> #+BEGIN_EQUATION
> c^{2} m
> #+END_EQUATION
>
> The problem I'm facing is that despite the fact that the equation is
> already in a mathematical mode latex environment, it still gets sub- and
> superscripts surrounded by a $ sign. Here is the generated latex snippet:
>
> \begin{equation}
> \label{eq:1}
> c$^{\text{2}}$ m
> \end{equation}
>
> Is there a way to teach org-mode not to insert $ signs in equation
> environments?
#+NAME: mass-energy
#+BEGIN_SRC python :results raw :exports results :post
import sympy as spreturn sp.latex(E, mode="inline")
E, m, c = sp.symbols('E, m, c', real=True, positive=True)
E = m*c**2
#+END_SRC
#+RESULTS: mass-energy
$c^{2} m$
Alternatively, if you need to combine stuff you could use the post
argument
#+name: wrapper
#+BEGIN_SRC emacs-lisp :var x=""
(format "\\(%s\\)" x)
#+END_SRC
#+NAME: mass-energy
#+BEGIN_SRC python :results raw :exports results :post wrapper(x=*this*)
import sympy as sp#+RESULTS: mass-energy
E, m, c = sp.symbols('E, m, c', real=True, positive=True)
E = m*c**2
return sp.latex(E)
#+END_SRC
\(c^{2} m\)
—Rasmus
--
El Rey ha muerto. ¡Larga vida al Rey!
[Prev in Thread] | Current Thread | [Next in Thread] |