Преглед изворни кода

Fix footnote problem with optional arguments to citation commands

Scot Beker writes:

> I cite my references in org like
> this.\autocite[231]{bibtexkey_2009}, where '231' is the
> relevant page number.  When exporting to LaTeX, Org thinks
> that the value in square brackets is a footnote number and
> produces a document with a "footnote definition not found:
> 231" error message at the bottom of the document.  My
> settings are below, and I've searched pretty hard through
> them to look for anything that might have caused it.  Any
> ideas?
Carsten Dominik пре 15 година
родитељ
комит
88cf58802c
3 измењених фајлова са 11 додато и 1 уклоњено
  1. 5 0
      lisp/ChangeLog
  2. 2 1
      lisp/org-footnote.el
  3. 4 0
      lisp/org.el

+ 5 - 0
lisp/ChangeLog

@@ -1,5 +1,10 @@
 2009-11-26  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-footnote.el (org-footnote-normalize): Don't take optional
+	arguments in LaTeX macros as footnotes.
+
+	* org.el (org-inside-latex-macro-p): New function.
+
 	* org-latex.el (org-latex-to-pdf-process): Change customization
 	group to `org-export-pdf'.
 

+ 2 - 1
lisp/org-footnote.el

@@ -366,7 +366,8 @@ referenced sequence."
       ;; Now find footnote references, and extract the definitions
       (goto-char (point-min))
       (while (re-search-forward org-footnote-re nil t)
-	(unless (or (org-in-commented-line) (org-in-verbatim-emphasis))
+	(unless (or (org-in-commented-line) (org-in-verbatim-emphasis)
+		    (org-inside-latex-macro-p))
 	  (org-if-unprotected
 	   (setq def (match-string 4)
 		 idef def

+ 4 - 0
lisp/org.el

@@ -14482,6 +14482,10 @@ looks only before point, not after."
 	(goto-char pos)
 	(if dd-on (cons "$$" m))))))
 
+(defun org-inside-latex-macro-p ()
+  "Is point inside a LaTeX macro or its arguments?"
+  (org-in-regexp
+   "\\\\[a-zA-Z]+\\*?\\(\\[[^][\n{}]*\\]\\)?\\({[^{}\n]*}\\)?"))
 
 (defun org-try-cdlatex-tab ()
   "Check if it makes sense to execute `cdlatex-tab', and do it if yes.