diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-04-17 20:57:21 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2013-04-17 20:59:41 +0200 |
commit | d57b9e84e16b7a9434c5ef0f0728f82c8cb6a9d8 (patch) | |
tree | a8bb8467e9c834c742e044f08067a788736420c9 | |
parent | 79ecb6570b7dabe2321f4bc36450473e89f8d732 (diff) | |
download | org-mode-d57b9e84e16b7a9434c5ef0f0728f82c8cb6a9d8.tar.gz |
ox-latex: Better handling of sub/superscript within sub/superscript
* lisp/ox-latex.el (org-latex--script-size): Fix error when using
sub/superscript within sub/superscript.
-rw-r--r-- | lisp/ox-latex.el | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index dafb991..dd8f774 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2205,7 +2205,17 @@ holding contextual information." "Transcode a subscript or superscript object. OBJECT is an Org object. INFO is a plist used as a communication channel." - (let ((output "")) + (let ((in-script-p + ;; Non-nil if object is already in a sub/superscript. + (let ((parent object)) + (catch 'exit + (while (setq parent (org-export-get-parent parent)) + (let ((type (org-element-type parent))) + (cond ((memq type '(subscript superscript)) + (throw 'exit t)) + ((memq type org-element-all-elements) + (throw 'exit nil)))))))) + (output "")) (org-element-map (org-element-contents object) (cons 'plain-text org-element-all-objects) (lambda (obj) @@ -2235,10 +2245,15 @@ channel." (let ((blank (org-element-property :post-blank obj))) (and blank (> blank 0) "\\ "))))))) info nil org-element-recursive-objects) - ;; Result. - (format (if (= (length output) 1) "$%s%s$" "$%s{%s}$") + ;; 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) "$") (if (eq (org-element-type object) 'subscript) "_" "^") - output))) + (and (> (length output) 1) "{") + output + (and (> (length output) 1) "}") + (and (not in-script-p) "$")))) (defun org-latex-subscript (subscript contents info) "Transcode a SUBSCRIPT object from Org to LaTeX. |