Bläddra i källkod

org-e-latex: Don't use mathrm in sub/superscripts with a single LaTeX command or entity

* contrib/lisp/org-e-latex.el (org-e-latex-subscript,
  org-e-latex-superscript): Don't use mathrm in sub/superscripts with
  a single LaTeX command or entity.
Nicolas Goaziou 12 år sedan
förälder
incheckning
d80661e764
1 ändrade filer med 16 tillägg och 2 borttagningar
  1. 16 2
      contrib/lisp/org-e-latex.el

+ 16 - 2
contrib/lisp/org-e-latex.el

@@ -2151,7 +2151,14 @@ holding contextual information."
   "Transcode a SUBSCRIPT object from Org to LaTeX.
 CONTENTS is the contents of the object.  INFO is a plist holding
 contextual information."
-  (format (if (= (length contents) 1) "$_%s$" "$_{\\mathrm{%s}}$") contents))
+  (format (if (or (= (length contents) 1)
+		  (let ((parsed-contents (org-element-contents subscript)))
+		    (and (not (cdr parsed-contents))
+			 (memq (org-element-type (car parsed-contents))
+			       '(entity latex-fragment)))))
+	      "$_%s$"
+	    "$_{\\mathrm{%s}}$")
+	  contents))
 
 
 ;;;; Superscript
@@ -2160,7 +2167,14 @@ contextual information."
   "Transcode a SUPERSCRIPT object from Org to LaTeX.
 CONTENTS is the contents of the object.  INFO is a plist holding
 contextual information."
-  (format (if (= (length contents) 1) "$^%s$" "$^{\\mathrm{%s}}$") contents))
+  (format (if (or (= (length contents) 1)
+		  (let ((parsed-contents (org-element-contents superscript)))
+		    (and (not (cdr parsed-contents))
+			 (memq (org-element-type (car parsed-contents))
+			       '(entity latex-fragment)))))
+	      "$^%s$"
+	    "$^{\\mathrm{%s}}$")
+	  contents))
 
 
 ;;;; Table