emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] curly nested latex fragments (was: superscript not available


From: heroxbd
Subject: [O] [PATCH] curly nested latex fragments (was: superscript not available after non-alphanumeric)
Date: Sun, 29 Jun 2014 20:47:57 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hello Nicolas,

Nicolas Goaziou <address@hidden> writes:

> If you want to insert raw LaTeX in an Org buffer, then \ce{^{238}U} is
> invalid because you cannot nest braces. You can write instead:
>
>   @@latex:\ce{^{238}U}@@
>
> or you can define a macro, e.g.,:
>
>   #+MACRO: ce @@latex:\ce{$1}@@
>
> and then use
>
>   {{{ce(^{238}U)}}}

Nesting braces is already implemented in the classic org-latex.el[1],
and is forward ported into org-element.el.  Would you like to take a
look at the attached patch? Thanks.

> Also, ^2H is not recognized as superscript _on purpose_. Per Org syntax,
> you have to add a non-blank character before the caret. Otherwise, there
> would be ambiguity between underline (e.g., _under_) and subscript
> (_under). And superscript syntax follows subscript's.
>
> In this case, you can probably use a math snippet, e.g.,
>
>   \(^2\)H

If \ce{^2H} works as above, it is not a problem for me.  Although make
it configurable is more user-friendly; "^:{}" is already there afterall,
adding another style feels natural.

Thanks,
Benda

1. 
http://orgmode.org/w/org-mode.git?p=org-mode.git;a=blob;f=lisp/org-latex.el;hb=107f921d121f5a9bb5a9324f19339e4435633d2d#l2597

support nested curly bracket pairs in latex fragments.

http://lists.gnu.org/archive/html/emacs-orgmode/2014-06/msg01022.html

Index: org-8.2.7b/lisp/org-element.el
===================================================================
--- org-8.2.7b.orig/lisp/org-element.el
+++ org-8.2.7b/lisp/org-element.el
@@ -3026,7 +3026,12 @@ Assume point is at the beginning of the
                                   (looking-at latex-regexp))))
                    (throw 'exit (nth 2 e)))))
              ;; None found: it's a macro.
-             (looking-at 
"\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*")
+             (looking-at (concat
+                          "\\\\\\([a-zA-Z]+\\*?\\)"
+                          "\\(?:<[^<>\n]*>\\)*"
+                          "\\(?:\\[[^][\n]*?\\]\\)*"
+                          "\\(?:<[^<>\n]*>\\)*"
+                          "\\(" (org-create-multibrace-regexp "{" "}" 3) 
"\\)\\{1,3\\}"))
              0))
           (value (org-match-string-no-properties substring-match))
           (post-blank (progn (goto-char (match-end substring-match))
Index: org-8.2.7b/doc/org.texi
===================================================================
--- org-8.2.7b.orig/doc/org.texi
+++ org-8.2.7b/doc/org.texi
@@ -10168,6 +10168,9 @@ any @LaTeX{} environment will be handled
 @code{\begin} and @code{\end} statements appear on a new line, at the
 beginning of the line or after whitespaces only.
 @item
+Commands like \command[...]{...} or \command{...}; the curly brakets could be
+nested up to 3 levels.
address@hidden
 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
 currency specifications, single @samp{$} characters are only recognized as
 math delimiters if the enclosed text contains at most two line breaks, is

reply via email to

[Prev in Thread] Current Thread [Next in Thread]