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