From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Regier Subject: Named latex blocks for inline execution? Date: Fri, 14 Mar 2014 10:25:57 -0500 (CDT) Message-ID: <772126696.634943.1394810757105.JavaMail.zimbra@ittc.ku.edu> References: <1549029341.634736.1394809114208.JavaMail.zimbra@ittc.ku.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTzv-0005hf-7F for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 11:26:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WOTzk-0008Fy-TI for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 11:26:11 -0400 Received: from stephens.ittc.ku.edu ([129.237.125.220]:36889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WOTzk-0008Ft-Mt for emacs-orgmode@gnu.org; Fri, 14 Mar 2014 11:26:00 -0400 Received: from zimbra.ittc.ku.edu (zimbra.ittc.ku.edu [129.237.125.105]) by stephens.ittc.ku.edu (Postfix) with ESMTP id CFDFA9400D2 for ; Fri, 14 Mar 2014 10:25:56 -0500 (CDT) Received: from zimbra.ittc.ku.edu (localhost.localdomain [127.0.0.1]) by zimbra.ittc.ku.edu (Postfix) with ESMTP id 5D159C28F0 for ; Fri, 14 Mar 2014 10:25:57 -0500 (CDT) Received: from zimbra.ittc.ku.edu (zimbra.ittc.ku.edu [129.237.125.105]) by zimbra.ittc.ku.edu (Postfix) with ESMTP id 52DB3C1D8A for ; Fri, 14 Mar 2014 10:25:57 -0500 (CDT) In-Reply-To: <1549029341.634736.1394809114208.JavaMail.zimbra@ittc.ku.edu> 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: org mode Hi, all; sorry to pester again, but I haven't been able to find a way to do something I would have thought would be relatively simple. What I want to do is declare a named latex block in Org which I can use to reproduce markup patterns which I reuse very frequently; the usual reasons include readability, brevity, and maintainability. The reasons I don't want to use Latex macros for this include: 1. Inflexibility of macro names in Latex (no digits or special characters allowed) 2. Unavailability of short macro names (most of the good ones are taken, so my schemes end up inconsistent or self-defeatingly long or I get subtle mysterious errors from overriding short macro names) 3. By mixing Org calls with Latex macros I can debug problems at multiple levels (by examining my Org source and generated Latex source separately, which is messier with Latex macros alone) 4. I can shield my advisor from my worst coding habits if he wants to read my Latex source 5. I can pass parameters/variables between Org blocks, performing computations on them when needed, more readily than Latex macros (and I would dearly love to follow real examples of numerical algorithm execution inline with the discussion of said algorithms), perhaps even marking Octave results up as Latex invisibly if I'm lucky. So I thought I would begin with a simple block to create a small inline bracketed matrix: #+name: Smx #+begin_src latex :var Contents="\\\\pi" \( \left[ \begin{smallmatrix} Contents \end{smallmatrix} \right] \) #+end_src What I get in a Latex export buffer from "call_Smx()" invariably is some variant of the following: =$\backslash$( \left[ \begin{smallmatrix} \Pi \end{smallmatrix} \right] $\backslash$)= There are several particularly stubborn issues here: 1. The surrounding '=' symbols have been impossible to eliminate. I assume they are part of an attempt to add code markdown, but Latex does not interpret them as such; they just get passed through. 2. The \( and \) directives get literalized no matter what I try. Wrapping the call in math mode delimiters hasn't been terribly fruitful either, as this seems to confuse the export (either inline math mode never gets entered, or the call_Smx() becomes literal text within math mode). 3. For some reason, my "\pi" gets capitalized in the Latex output. I'm not sure exactly what I expect from any particular syntax, but what I want is just an interpretable stamp of the Latex code inside the original block with variables substituted exactly. I've tried extra backslashes in the code, tried a variety of [:results ...] and [:exports ...] before and after the call (as well as prologues and epilogues), exporting to raw and latex and org, and even declaring the block as org instead of latex. Is there a correct way to achieve this, or am I trying to make Org do something it is not meant to do? Thanks for any ideas... Phil