From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cOXzMykeWmDEEAAA0tVLHw (envelope-from ) for ; Tue, 23 Mar 2021 16:58:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QLyrLykeWmDaOAAAbx9fmQ (envelope-from ) for ; Tue, 23 Mar 2021 16:58:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id ED16A922F for ; Tue, 23 Mar 2021 17:58:16 +0100 (CET) Received: from localhost ([::1]:34178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOkMB-0003mJ-3K for larch@yhetil.org; Tue, 23 Mar 2021 12:58:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOjmL-0004Sd-4m for emacs-orgmode@gnu.org; Tue, 23 Mar 2021 12:21:13 -0400 Received: from mail-40141.protonmail.ch ([185.70.40.141]:44243) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOjmI-0002df-54 for emacs-orgmode@gnu.org; Tue, 23 Mar 2021 12:21:12 -0400 Date: Tue, 23 Mar 2021 16:21:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.ch; s=protonmail; t=1616516465; bh=X+zXlfGOo9+2kEIuegV71+5FZaXkwR6E/P/eKV7QOPM=; h=Date:To:From:Reply-To:Subject:From; b=w5eEGcsGXudKYBw7b/ZxT+sBvo9u5gEklTQ6r40v24RRyrryjoO9VPWJoM1kfxap4 NQV9Iy2SBi2s0e9RUuJzmDqQmheV8jcQ9wdjMTIdZ01Y/b+sAtBny8CsuK/KApihnG HsS/byh6MSbXnunusPG6OUNlx/GU7elKvst9plb0= To: "emacs-orgmode@gnu.org" From: autofrettage Subject: SymPy equations + displayed equation + label = difficult? Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.141; envelope-from=autofrettage@protonmail.ch; helo=mail-40141.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: autofrettage Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616518697; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=X+zXlfGOo9+2kEIuegV71+5FZaXkwR6E/P/eKV7QOPM=; b=iadlAQdhSdhlvP3h76/rLQu1mrBn6PlLuJzlhwVYhh+bvFs47TzuAIaGWG3hhjVJlMDHDK A9I3/q3AGQwsE8fVG8/rIoquc6aM3iaWT7M8p6WuHlq+NMs6SGLIaH3PVBhOCs6XmNZ6Ck XysM1OJ3oSuWYL+AHrfB7ofIF2DFRZTNN1wTEhXtaWC1NGYKJWI5c6zwiPnYCHG7kdK26i WQWGQnSe/sKE6WRHjrti5JLTNXmKebqtYfxhg7QJ0h8Lu1a6vuC6oacJDuy82gwFmkJ7zr hp5lXZersEQ28hDZLQZ2xL2E9I9oP0UTUzvBVPTIJ/XZ4IVabC4oFB9JNiSb/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616518697; a=rsa-sha256; cv=none; b=j3VnPDOzt3g3XRWwD7JFfpQNGFdKaho2ITjfvE3W/waDzgy/xjoLaAKfb3J4As3gNCMy5d ntrrrJQ9sHojfH+BjF3TH8Zic2QgpDlMr9POhPvSQtHMjzzrNHarPi4Q6qxx2tszr32Vhl 9jJSBWSaHFZSpFrHJyJRT8zFAKRn/xZkklBMcuI9b+ybboZu2rASoIuYNBr6Ngtl6jcY2/ k9ssdEO7PHqqEYWiXYO8njRmQPKt5TciOnuzvpJjYk59uTib/ipkdmkb6fNTMHmKF/jiO+ 3X8EqW6Ad43zPKNJl17mpiEuPP/DyB0KLP68fcfZ80gGPZD2WwsTYQlM3WAo8w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=protonmail.ch header.s=protonmail header.b=w5eEGcsG; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.12 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.ch header.s=protonmail header.b=w5eEGcsG; dmarc=pass (policy=quarantine) header.from=protonmail.ch; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: ED16A922F X-Spam-Score: -2.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: RKIkFDVayHVU Hi all, I have tried to use SymPy in Org Mode code blocks, export LaTeX expressions to displayed equations, and refer to those with labels. My current solution is ugly, which has left me with a strong feeling that there must be a better way. Sensitive Org Mode users are warned. Here comes a brief description of my current solution. * The equation is defined inside a SymPy block, e.g.: a, R, L =3D symbols('\\alpha R L') equ =3D Eq(R, L * sin(a)) * The LaTeX representation for equ, and the rest of the LaTeX code needed for producing a displayed equation, with a label, are generated with the Python function expequ: #+BEGIN_SRC python :session :results none :exports none def expequ(expr, label): # will write out code for export of SymPy equation expression =3D latex(expr, mode=3D"plain") print(""" \\begin{equation} \\label{%(label)s} %(expr)s \\end{equation}""" % {'expr': expression, 'label': label}) #+END_SRC * At the place where I want to display equ, I call expequ like this: #+HEADER: :results output latex overwrite :exports results #+BEGIN_SRC python :session expequ(equ2,"equ:labeltest") #+END_SRC * ...which yields: #+RESULTS: #+BEGIN_EXPORT latex \begin{equation} \label{equ:labeltest} R =3D L \sin{\left(\alpha \right)} \end{equation} #+END_EXPORT How many painfully obvious solutions have I missed? Yours Rasmus