emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: heroxbd@gentoo.org
To: emacs-orgmode@gnu.org
Subject: [PATCH] curly nested latex fragments (was: superscript not available after non-alphanumeric)
Date: Sun, 29 Jun 2014 20:47:57 +0900	[thread overview]
Message-ID: <86pphshr82.fsf_-_@moguhome00.in.awa.tohoku.ac.jp> (raw)
In-Reply-To: <878uoiy3bd.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Fri, 27 Jun 2014 13:55:34 +0200")

[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]

Hello Nicolas,

Nicolas Goaziou <mail@nicolasgoaziou.fr> 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.


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-8.2.7b_element-latex-nested-curly.patch --]
[-- Type: text/x-patch, Size: 1618 bytes --]

support nested curly bracket pairs in latex fragments.


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\\}"))
 	   (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.
+Commands like \command[...]{...} or \command{...}; the curly brakets could be
+nested up to 3 levels.
 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

  parent reply	other threads:[~2014-06-29 11:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 10:42 Bug: [regression] superscript not available after non-alphanumeric [8.2.7b (8.2.7b-dist @ /home/benda/gnto/usr/share/emacs/site-lisp/org-mode/)] heroxbd
2014-06-27 11:55 ` Nicolas Goaziou
2014-06-28  1:39   ` syntax specification (was Re: Bug: [regression] superscript not available after non-alphanumeric) heroxbd
2014-06-29 11:47   ` heroxbd [this message]
2014-06-29 13:53     ` [PATCH] curly nested latex fragments Nicolas Goaziou
2014-06-30  0:38       ` heroxbd
2014-06-30 12:31         ` Nicolas Goaziou
2014-06-30 21:50           ` heroxbd
2014-07-06 20:11             ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86pphshr82.fsf_-_@moguhome00.in.awa.tohoku.ac.jp \
    --to=heroxbd@gentoo.org \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).