From mboxrd@z Thu Jan 1 00:00:00 1970 From: Federico Beffa Subject: Re: latex equations and $ sign Date: Wed, 9 Jul 2014 15:31:18 +0200 Message-ID: References: <8738fixevg.fsf@gmx.us> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c38b8c23fbbc04fdc2b93c Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4rxy-0006MU-Jp for emacs-orgmode@gnu.org; Wed, 09 Jul 2014 09:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4rxw-0004Z7-JP for emacs-orgmode@gnu.org; Wed, 09 Jul 2014 09:31:22 -0400 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:33811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4rxw-0004YV-70 for emacs-orgmode@gnu.org; Wed, 09 Jul 2014 09:31:20 -0400 Received: by mail-lb0-f175.google.com with SMTP id n15so5056911lbi.34 for ; Wed, 09 Jul 2014 06:31:18 -0700 (PDT) In-Reply-To: <8738fixevg.fsf@gmx.us> 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 --001a11c38b8c23fbbc04fdc2b93c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Ramus, yes, the reason is that, differently from $...$ and \(...\), an equation environment produces a *numbered* equation to which you can add a label and reference the equation by (label) name in other parts of the text. This is not possibly with unnumbered math environments ($$, ...). Regards, Fede On Fri, Jun 6, 2014 at 5:00 PM, Rasmus wrote: > 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 =3D sp.symbols('E, m, c', real=3DTrue, positive=3DTrue) > > E =3D 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- an= d > > superscripts surrounded by a $ sign. Here is the generated latex snippe= t: > > > > \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 =3D sp.symbols('E, m, c', real=3DTrue, positive=3DTrue) > E =3D m*c**2 > return sp.latex(E, mode=3D"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=3D"" > (format "\\(%s\\)" x) > #+END_SRC > > #+NAME: mass-energy > #+BEGIN_SRC python :results raw :exports results :post > wrapper(x=3D*this*) > import sympy as sp > E, m, c =3D sp.symbols('E, m, c', real=3DTrue, positive=3DTrue) > E =3D m*c**2 > return sp.latex(E) > #+END_SRC > > #+RESULTS: mass-energy > \(c^{2} m\) > > =E2=80=94Rasmus > > -- > El Rey ha muerto. =C2=A1Larga vida al Rey! > > > --001a11c38b8c23fbbc04fdc2b93c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Ramus,

yes, the reason is t= hat,=20 differently from $...$ and \(...\), an equation environment produces a=20 *numbered* equation to which you can add a label and reference the=20 equation by (label) name in other parts of the text. This is not=20 possibly with unnumbered math environments ($$, ...).

Regards,
Fede

=
On Fri, Jun 6, 2014 at 5:00 PM, Rasmus <rasmus@gmx.us> wrote:
Federico Beffa <beffa@ieee.org> writes:

> Hi,
>
> I would like to have a mathematical equation typeset in latex and
> automatically generated by sympy, embedded in an equation environment:=
>
> =C2=A0 #+NAME: mass-energy
> =C2=A0 #+BEGIN_SRC python :results raw :exports results :wrap EQUATION=
> =C2=A0 =C2=A0 import sympy as sp
> =C2=A0 =C2=A0 E, m, c =3D sp.symbols('E, m, c', real=3DTrue, p= ositive=3DTrue)
> =C2=A0 =C2=A0 E =3D m*c**2
> =C2=A0 =C2=A0 return sp.latex(E)
> =C2=A0 #+END_SRC
>
>
> =C2=A0 #+NAME: eq:1
> =C2=A0 #+RESULTS: mass-energy
> =C2=A0 #+BEGIN_EQUATION
> =C2=A0 c^{2} m
> =C2=A0 #+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- a= nd
> superscripts surrounded by a $ sign. Here is the generated latex snipp= et:
>
> \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:<= br>
=C2=A0 =C2=A0 #+NAME: mass-energy
=C2=A0 =C2=A0 #+BEGIN_SRC python :results raw :exports results :post
=C2=A0 =C2=A0 =C2=A0 import sympy as sp
=C2=A0 =C2=A0 =C2=A0 E, m, c =3D sp.symbols('E, m, c', real=3DTrue,= positive=3DTrue)
=C2=A0 =C2=A0 =C2=A0 E =3D m*c**2
=C2=A0 =C2=A0 =C2=A0 return sp.latex(E, mode=3D"inline") =C2=A0 =C2=A0 #+END_SRC

=C2=A0 =C2=A0 #+RESULTS: mass-energy
=C2=A0 =C2=A0 $c^{2} m$


Alternatively, if you need to combine stuff you could use the post
argument

=C2=A0 =C2=A0 #+name: wrapper
=C2=A0 =C2=A0 #+BEGIN_SRC emacs-lisp :var x=3D""
=C2=A0 =C2=A0 (format "\\(%s\\)" x)
=C2=A0 =C2=A0 #+END_SRC

=C2=A0 =C2=A0 #+NAME: mass-energy
=C2=A0 =C2=A0 #+BEGIN_SRC python :results raw :exports results :post wrappe= r(x=3D*this*)
=C2=A0 =C2=A0 =C2=A0 import sympy as sp
=C2=A0 =C2=A0 =C2=A0 E, m, c =3D sp.symbols('E, m, c', real=3DTrue,= positive=3DTrue)
=C2=A0 =C2=A0 =C2=A0 E =3D m*c**2
=C2=A0 =C2=A0 =C2=A0 return sp.latex(E)
=C2=A0 =C2=A0 #+END_SRC

=C2=A0 =C2=A0 #+RESULTS: mass-energy
=C2=A0 =C2=A0 \(c^{2} m\)

=E2=80=94Rasmus

--
El Rey ha muerto. =C2=A1Larga vida al Rey!



--001a11c38b8c23fbbc04fdc2b93c--