diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-04-18 00:06:06 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-04-18 00:06:06 +0200 |
commit | 77c5710de2256dd19a1b05ea8411e787f611a515 (patch) | |
tree | 001be1a1ea569fe1397331b82099aa9ef11b7c76 | |
parent | 58f7e4382101b555fe7d6af460bfa2fb6208adb5 (diff) | |
download | org-mode-77c5710de2256dd19a1b05ea8411e787f611a515.tar.gz |
ox-latex: Handle consecutive alterning sub and superscript
* lisp/ox-latex.el (org-latex--script-size): Handle consecutive
alterning sub and superscript.
This patch fixes export of "a^b_c" constructs.
-rw-r--r-- | lisp/ox-latex.el | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index c6fb9a0..2a315ef 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2215,6 +2215,7 @@ channel." (throw 'exit t)) ((memq type org-element-all-elements) (throw 'exit nil)))))))) + (type (org-element-type object)) (output "")) (org-element-map (org-element-contents object) (cons 'plain-text org-element-all-objects) @@ -2242,13 +2243,29 @@ channel." info nil org-element-recursive-objects) ;; Result. Do not wrap into math mode if already in a subscript ;; or superscript. Do not wrap into curly brackets if OUTPUT is - ;; a single character. - (concat (and (not in-script-p) "$") + ;; a single character. Also merge consecutive subscript and + ;; superscript into the same math snippet. + (concat (and (not in-script-p) + (let ((prev (org-export-get-previous-element object info))) + (or (not prev) + (not (eq (org-element-type prev) + (if (eq type 'subscript) 'superscript + 'subscript))) + (let ((blank (org-element-property :post-blank prev))) + (and blank (> blank 0))))) + "$") (if (eq (org-element-type object) 'subscript) "_" "^") (and (> (length output) 1) "{") output (and (> (length output) 1) "}") - (and (not in-script-p) "$")))) + (and (not in-script-p) + (or (let ((blank (org-element-property :post-blank object))) + (and blank (> blank 0))) + (not (eq (org-element-type + (org-export-get-next-element object info)) + (if (eq type 'subscript) 'superscript + 'subscript)))) + "$")))) (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX. |