Browse Source

LaTeX export: Fix superscript bug

Thomas S. Dye writes:

> I'm trying to generate $^{14}$C, or an equivalent, from org-mode
> to represent the isotope of carbon important in archaeological
> dating.
>
> Reading the manual, I tried this:
>
> ** A Brief History of Attempts to Interpret the ^{14}C Dates
> *** The ^{14}C Dates
>
> Which, in my #+LaTeX_CLASS: beamer export, yields
>
> \subsection{A Brief History of Attempts to Interpret the \^{}{14}C Dates}
> ...
> \begin{frame}\frametitle{The \^{}{14}C Dates}
>
> The problem seems to be the space before the ^.
>
> This input:
>
> ** A Brief History of Attempts to Interpret the x^{14}C Dates
> *** The x^{14}C Dates
>
> yields the correct LaTeX:
>
> \subsection{A Brief History of Attempts to Interpret the x$^{\mathrm{14}}$C Dates}
> ...
> \begin{frame}\frametitle{The x$^{\mathrm{14}}$C Dates}
>
> Am I missing something?  Or, is the LaTeX export thrown off by
> the space before ^?

Indeed, a space before the caret was not allowed in LaTeX export
Carsten Dominik 15 years ago
parent
commit
7d5408a717
2 changed files with 7 additions and 3 deletions
  1. 5 0
      lisp/ChangeLog
  2. 2 3
      lisp/org-latex.el

+ 5 - 0
lisp/ChangeLog

@@ -1,3 +1,8 @@
+2009-09-29  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-latex.el (org-export-latex-treat-sub-super-char): Allow a
+	space character as the character before the ^/_.
+
 2009-09-28  Carsten Dominik  <carsten.dominik@gmail.com>
 
 	* org-macs.el (org-if-unprotected-at): Fix docstring.

+ 2 - 3
lisp/org-latex.el

@@ -1232,9 +1232,8 @@ SUBSUP corresponds to the ^: option in the #+OPTIONS line.
 Convert CHAR depending on STRING-BEFORE and STRING-AFTER."
   (cond ((equal string-before "\\")
 	 (concat string-before char string-after))
-	;; this is part of a math formula
-	((and (string-match "\\S-+" string-before)
-	      (string-match "\\S-+" string-after))
+	((and (string-match "\\S-+" string-after))
+	 ;; this is part of a math formula
 	 (cond ((eq 'org-link (get-text-property 0 'face char))
 		(concat string-before "\\" char string-after))
 	       ((save-match-data (org-inside-latex-math-p))