Browse Source

Export: Try to do a better job with LaTeX math.

Fixes some issues reported by Rasmus Pank Roulund.
Carsten Dominik 16 years ago
parent
commit
0782fbf785
2 changed files with 5 additions and 3 deletions
  1. 2 2
      lisp/org-export-latex.el
  2. 3 1
      lisp/org.el

+ 2 - 2
lisp/org-export-latex.el

@@ -1267,11 +1267,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
     (while (setq e (pop re-list))
       (setq m (car e) re (nth 1 e) n (nth 2 e)
 	    block (if (nth 3 e) "\n\n" ""))
-      (setq off (if (equal m "$") 1 0))
+      (setq off (if (member m '("$" "$1")) 1 0))
       (when (and (member m matchers) (not (equal m "begin")))
 	(goto-char (point-min))
 	(while (re-search-forward re nil t)
-	  (setq beg (+ (match-beginning 0) off) end (- (match-end 0) off))
+	  (setq beg (+ (match-beginning 0) off) end (- (match-end 0) 0))
 	  (add-text-properties beg end '(org-protected t org-latex-math t))))))
 
   ;; Convert LaTeX to \LaTeX{}

+ 3 - 1
lisp/org.el

@@ -2235,7 +2235,7 @@ default is the character `k' because we use the same key in the agenda."
 (defcustom org-format-latex-options
   '(:foreground default :background default :scale 1.0
     :html-foreground "Black" :html-background "Transparent" :html-scale 1.0
-    :matchers ("begin" "$" "$$" "\\(" "\\["))
+    :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
   "Options for creating images from LaTeX fragments.
 This is a property list with the following properties:
 :foreground  the foreground color for images embedded in Emacs, e.g. \"Black\".
@@ -2248,6 +2248,7 @@ This is a property list with the following properties:
 :matchers    a list indicating which matchers should be used to
              find LaTeX fragments.  Valid members of this list are:
              \"begin\"  find environments
+             \"$1\"     find single characters surrounded by $.$
              \"$\"      find math expressions surrounded by $...$
              \"$$\"     find math expressions surrounded by $$....$$
              \"\\(\"     find math expressions surrounded by \\(...\\)
@@ -12466,6 +12467,7 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]."
   '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t)
     ;; ("$" "\\([ 	(]\\|^\\)\\(\\(\\([$]\\)\\([^ 	\r\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ 	\r\n,.$]\\)\\4\\)\\)\\([ 	.,?;:'\")]\\|$\\)" 2 nil)
     ;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p
+    ("$1" "\\([^$]\\)\\(\\$[^ 	\r\n,;.$]\\$\\)\\([- 	.,?;:'\")\000]\\|$\\)" 2 nil)
     ("$" "\\([^$]\\)\\(\\(\\$\\([^ 	\r\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ 	\r\n,.$]\\)\\$\\)\\)\\([- 	.,?;:'\")\000]\\|$\\)" 2 nil)
     ("\\(" "\\\\([^\000]*?\\\\)" 0 nil)
     ("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 t)