forked from mirrors/org-mode
org-e-latex: Allow multiple objects and spaces in sub/superscript
* contrib/lisp/org-e-latex.el (org-e-latex-subscript, org-e-latex-superscript): Allow multiple objects and spaces in sub/superscript.
This commit is contained in:
parent
1b64d9582e
commit
c92913b5f9
|
@ -2151,14 +2151,31 @@ holding contextual information."
|
||||||
"Transcode a SUBSCRIPT object from Org to LaTeX.
|
"Transcode a SUBSCRIPT object from Org to LaTeX.
|
||||||
CONTENTS is the contents of the object. INFO is a plist holding
|
CONTENTS is the contents of the object. INFO is a plist holding
|
||||||
contextual information."
|
contextual information."
|
||||||
(format (if (or (= (length contents) 1)
|
(if (= (length contents) 1) (format "$_%s$" contents)
|
||||||
(let ((parsed-contents (org-element-contents subscript)))
|
;; Handle multiple objects in SUBSCRIPT by creating a subscript
|
||||||
(and (not (cdr parsed-contents))
|
;; command for each of them.
|
||||||
(memq (org-element-type (car parsed-contents))
|
(let ((prev-blanks 0))
|
||||||
'(entity latex-fragment)))))
|
(mapconcat
|
||||||
"$_%s$"
|
(lambda (obj)
|
||||||
"$_{\\mathrm{%s}}$")
|
(case (org-element-type obj)
|
||||||
contents))
|
((entity latex-fragment)
|
||||||
|
(setq prev-blanks (org-element-property :post-blank obj))
|
||||||
|
(let ((data (org-trim (org-export-data obj info))))
|
||||||
|
(string-match
|
||||||
|
"\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'"
|
||||||
|
data)
|
||||||
|
(format "$_{%s}$" (match-string 1 data))))
|
||||||
|
(plain-text
|
||||||
|
(format "$_\\mathrm{%s}$"
|
||||||
|
(concat (make-string prev-blanks ? )
|
||||||
|
;; mathrm command doesn't handle spaces,
|
||||||
|
;; so we have to enforce them.
|
||||||
|
(replace-regexp-in-string
|
||||||
|
" " "\\\\ " (org-export-data obj info)))))
|
||||||
|
(otherwise
|
||||||
|
(setq prev-blanks (org-element-property :post-blank obj))
|
||||||
|
(format "$_{%s}$" (org-export-data obj info)))))
|
||||||
|
(org-element-contents subscript) ""))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Superscript
|
;;;; Superscript
|
||||||
|
@ -2167,14 +2184,31 @@ contextual information."
|
||||||
"Transcode a SUPERSCRIPT object from Org to LaTeX.
|
"Transcode a SUPERSCRIPT object from Org to LaTeX.
|
||||||
CONTENTS is the contents of the object. INFO is a plist holding
|
CONTENTS is the contents of the object. INFO is a plist holding
|
||||||
contextual information."
|
contextual information."
|
||||||
(format (if (or (= (length contents) 1)
|
(if (= (length contents) 1) (format "$^%s$" contents)
|
||||||
(let ((parsed-contents (org-element-contents superscript)))
|
;; Handle multiple objects in SUPERSCRIPT by creating
|
||||||
(and (not (cdr parsed-contents))
|
;; a superscript command for each of them.
|
||||||
(memq (org-element-type (car parsed-contents))
|
(let ((prev-blanks 0))
|
||||||
'(entity latex-fragment)))))
|
(mapconcat
|
||||||
"$^%s$"
|
(lambda (obj)
|
||||||
"$^{\\mathrm{%s}}$")
|
(case (org-element-type obj)
|
||||||
contents))
|
((entity latex-fragment)
|
||||||
|
(setq prev-blanks (org-element-property :post-blank obj))
|
||||||
|
(let ((data (org-trim (org-export-data obj info))))
|
||||||
|
(string-match
|
||||||
|
"\\`\\(?:\\\\[([]\\|\\$+\\)?\\(.*?\\)\\(?:\\\\[])]\\|\\$+\\)?\\'"
|
||||||
|
data)
|
||||||
|
(format "$^{%s}$" (match-string 1 data))))
|
||||||
|
(plain-text
|
||||||
|
(format "$^\\mathrm{%s}$"
|
||||||
|
(concat (make-string prev-blanks ? )
|
||||||
|
;; mathrm command doesn't handle spaces,
|
||||||
|
;; so we have to enforce them.
|
||||||
|
(replace-regexp-in-string
|
||||||
|
" " "\\\\ " (org-export-data obj info)))))
|
||||||
|
(otherwise
|
||||||
|
(setq prev-blanks (org-element-property :post-blank obj))
|
||||||
|
(format "$^{%s}$" (org-export-data obj info)))))
|
||||||
|
(org-element-contents superscript) ""))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Table
|
;;;; Table
|
||||||
|
|
Loading…
Reference in a new issue