From mboxrd@z Thu Jan 1 00:00:00 1970 From: heroxbd@gentoo.org Subject: [PATCH] curly nested latex fragments (was: superscript not available after non-alphanumeric) Date: Sun, 29 Jun 2014 20:47:57 +0900 Message-ID: <86pphshr82.fsf_-_@moguhome00.in.awa.tohoku.ac.jp> References: <86simqocpz.fsf@moguhome00.in.awa.tohoku.ac.jp> <878uoiy3bd.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1Dac-0006yw-Cg for emacs-orgmode@gnu.org; Sun, 29 Jun 2014 07:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1DaX-00022X-AH for emacs-orgmode@gnu.org; Sun, 29 Jun 2014 07:48:10 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:49964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1DaX-0001zJ-3x for emacs-orgmode@gnu.org; Sun, 29 Jun 2014 07:48:05 -0400 Received: from moguhome00.in.awa.tohoku.ac.jp (ernie02-dmz.awa.tohoku.ac.jp [130.34.99.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: heroxbd) by smtp.gentoo.org (Postfix) with ESMTPSA id 97ACB33FF71 for ; Sun, 29 Jun 2014 11:48:02 +0000 (UTC) In-Reply-To: <878uoiy3bd.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Fri, 27 Jun 2014 13:55:34 +0200") 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 --=-=-= Content-Type: text/plain Hello Nicolas, Nicolas Goaziou 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=org-8.2.7b_element-latex-nested-curly.patch 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. +@item 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 --=-=-=--