From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: latex equations and $ sign Date: Fri, 06 Jun 2014 17:00:03 +0200 Message-ID: <8738fixevg.fsf@gmx.us> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsvaV-0006T6-Kb for emacs-orgmode@gnu.org; Fri, 06 Jun 2014 10:57:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsvaO-00018c-U3 for emacs-orgmode@gnu.org; Fri, 06 Jun 2014 10:57:47 -0400 Received: from plane.gmane.org ([80.91.229.3]:38335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsvaO-00018X-Ne for emacs-orgmode@gnu.org; Fri, 06 Jun 2014 10:57:40 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WsvaM-0002V9-2v for emacs-orgmode@gnu.org; Fri, 06 Jun 2014 16:57:38 +0200 Received: from ip-pool-137.iue.it ([192.167.90.137]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Jun 2014 16:57:38 +0200 Received: from rasmus by ip-pool-137.iue.it with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 06 Jun 2014 16:57:38 +0200 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: emacs-orgmode@gnu.org Federico Beffa 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? Is there a reason you are not using a mode argument like this: #+NAME: mass-energy #+BEGIN_SRC python :results raw :exports results :post import sympy as sp E, m, c = sp.symbols('E, m, c', real=True, positive=True) E = m*c**2 return sp.latex(E, mode="inline") #+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 E, m, c = sp.symbols('E, m, c', real=True, positive=True) E = m*c**2 return sp.latex(E) #+END_SRC #+RESULTS: mass-energy \(c^{2} m\) —Rasmus -- El Rey ha muerto. ¡Larga vida al Rey!