* Named latex blocks for inline execution?
[not found] <1549029341.634736.1394809114208.JavaMail.zimbra@ittc.ku.edu>
@ 2014-03-14 15:25 ` Phil Regier
2014-03-14 16:54 ` Thomas S. Dye
2014-03-14 17:09 ` Eric S Fraga
0 siblings, 2 replies; 5+ messages in thread
From: Phil Regier @ 2014-03-14 15:25 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Named latex blocks for inline execution?
2014-03-14 15:25 ` Named latex blocks for inline execution? Phil Regier
@ 2014-03-14 16:54 ` Thomas S. Dye
2014-03-14 17:42 ` Phil Regier
2014-03-14 17:09 ` Eric S Fraga
1 sibling, 1 reply; 5+ messages in thread
From: Thomas S. Dye @ 2014-03-14 16:54 UTC (permalink / raw)
To: Phil Regier; +Cc: org mode
Aloha Phil,
Org mode has its own macros, which might work in this instance.
The variable org-babel-inline-result-wrap is set to "=%s=" by
default. Setting it as follows will get rid of the surrounding =
symbols:
#+begin_src emacs-lisp
(setq org-babel-inline-result-wrap "%s")
#+end_src
Alternatively, on my setup at least, call_Smx()[:results raw] will also
get rid of the surrounding = symbols.
The capitalization of "pi" seems to be related to capitalization of the
variable name "Contents". This is new to me and I don't recall reading
about it in the documentation, but I haven't looked lately. At any rate,
if I name the variable "contents" then I get a lowercase "pi" in the
output.
My guess about the "backslash" part is that Org mode is expecting an
inline LaTeX math snippet to be on one line. At any rate, this seems to
work for me:
#+name: Smx
#+begin_src latex :var contents="\\\\pi"
\begin{equation}
\left[
\begin{smallmatrix}
contents
\end{smallmatrix}
\right]
\end{equation}
#+end_src
hth,
Tom
Phil Regier <pregier@ittc.ku.edu> writes:
> 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
>
>
--
Thomas S. Dye
http://www.tsdye.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Named latex blocks for inline execution?
2014-03-14 15:25 ` Named latex blocks for inline execution? Phil Regier
2014-03-14 16:54 ` Thomas S. Dye
@ 2014-03-14 17:09 ` Eric S Fraga
2014-03-14 17:40 ` Phil Regier
1 sibling, 1 reply; 5+ messages in thread
From: Eric S Fraga @ 2014-03-14 17:09 UTC (permalink / raw)
To: Phil Regier; +Cc: org mode
Hello,
The following works for me with your example:
#+call: Smx[:exports results](Contents="Interesting") :results drawer latex
I am not sure why because I don't really understand the semantics of
"drawer" for results and didn't see anything in the docmentation about
this option (but also didn't look that hard for it).
--
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.1, Org release_8.2.5h-660-gef207f
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Named latex blocks for inline execution?
2014-03-14 17:09 ` Eric S Fraga
@ 2014-03-14 17:40 ` Phil Regier
0 siblings, 0 replies; 5+ messages in thread
From: Phil Regier @ 2014-03-14 17:40 UTC (permalink / raw)
To: Eric S Fraga; +Cc: org mode
Thanks so much, Eric; during my recent updates/testing I had wiped my drawer export settings and had not attempted to use drawer output. I will be sure to try it out. I'm not sure whether the positive results will carry over to the inline call_Smx() syntax, but this will be enlightening even if they do not.
Phil
----- Original Message -----
From: "Eric S Fraga" <e.fraga@ucl.ac.uk>
To: "Phil Regier" <pregier@ittc.ku.edu>
Cc: "org mode" <emacs-orgmode@gnu.org>
Sent: Friday, March 14, 2014 12:09:15 PM
Subject: Re: [O] Named latex blocks for inline execution?
Hello,
The following works for me with your example:
#+call: Smx[:exports results](Contents="Interesting") :results drawer latex
I am not sure why because I don't really understand the semantics of
"drawer" for results and didn't see anything in the docmentation about
this option (but also didn't look that hard for it).
--
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.1, Org release_8.2.5h-660-gef207f
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Named latex blocks for inline execution?
2014-03-14 16:54 ` Thomas S. Dye
@ 2014-03-14 17:42 ` Phil Regier
0 siblings, 0 replies; 5+ messages in thread
From: Phil Regier @ 2014-03-14 17:42 UTC (permalink / raw)
To: Thomas S. Dye; +Cc: org mode
Many thanks, Tom; these are all variations I had not thought to try. I will try them out and see what combination works best for me.
Phil
----- Original Message -----
From: "Thomas S. Dye" <tsd@tsdye.com>
To: "Phil Regier" <pregier@ittc.ku.edu>
Cc: "org mode" <emacs-orgmode@gnu.org>
Sent: Friday, March 14, 2014 11:54:04 AM
Subject: Re: Named latex blocks for inline execution?
Aloha Phil,
Org mode has its own macros, which might work in this instance.
The variable org-babel-inline-result-wrap is set to "=%s=" by
default. Setting it as follows will get rid of the surrounding =
symbols:
#+begin_src emacs-lisp
(setq org-babel-inline-result-wrap "%s")
#+end_src
Alternatively, on my setup at least, call_Smx()[:results raw] will also
get rid of the surrounding = symbols.
The capitalization of "pi" seems to be related to capitalization of the
variable name "Contents". This is new to me and I don't recall reading
about it in the documentation, but I haven't looked lately. At any rate,
if I name the variable "contents" then I get a lowercase "pi" in the
output.
My guess about the "backslash" part is that Org mode is expecting an
inline LaTeX math snippet to be on one line. At any rate, this seems to
work for me:
#+name: Smx
#+begin_src latex :var contents="\\\\pi"
\begin{equation}
\left[
\begin{smallmatrix}
contents
\end{smallmatrix}
\right]
\end{equation}
#+end_src
hth,
Tom
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-03-14 18:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1549029341.634736.1394809114208.JavaMail.zimbra@ittc.ku.edu>
2014-03-14 15:25 ` Named latex blocks for inline execution? Phil Regier
2014-03-14 16:54 ` Thomas S. Dye
2014-03-14 17:42 ` Phil Regier
2014-03-14 17:09 ` Eric S Fraga
2014-03-14 17:40 ` Phil Regier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).