Browse Source

LaTeX export: Protect secondary footnote references

Francesco Pizzolante writes:

> Exporting multiple references to the same footnote to LaTeX lead to a wrong
> generated code.
>
> The following example:
>
> --8<---------------cut here---------------start------------->8---
> * Title
>   This is my text[fn:1:This is my footnote.]. And another one[fn:1].
> --8<---------------cut here---------------end--------------->8---
>
> Will produce the following LaTeX code:
>
> --8<---------------cut here---------------start------------->8---
> \section{Title}
> \label{sec-1}
>
>   This is my text\footnote{This is my footnote. }. And another one\$$^{1}$\$.
> --8<---------------cut here---------------end--------------->8---
>
> The correct code should be:
>
> --8<---------------cut here---------------start------------->8---
> \section{Title}
> \label{sec-1}
>
>   This is my text\footnote{This is my footnote. }. And another one$^{1}$.
> --8<---------------cut here---------------end--------------->8---
Carsten Dominik 15 years ago
parent
commit
3f64f8ec73
2 changed files with 5 additions and 1 deletions
  1. 3 0
      lisp/ChangeLog
  2. 2 1
      lisp/org-latex.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-11-20  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-latex-preprocess): Protect secondary
+	footnote references.
+
 	* org-indent.el (org-indent-initialize): Avoid empty strings as
 	line prefixes.
 

+ 2 - 1
lisp/org-latex.el

@@ -1815,7 +1815,8 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 	   (save-excursion
 	     (if (not (re-search-forward (concat "^" (regexp-quote foot-prefix))
 					 nil t))
-		 (replace-match "$^{\\1}$")
+		 (replace-match (org-export-latex-protect-string
+				 (concat "$^{" (match-string 1) "}$")))
 	       (replace-match "")
 	       (let ((end (save-excursion
 			    (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t)