diff --git a/texmathp.el b/texmathp.el index 350406b..d4fa648 100644 --- a/texmathp.el +++ b/texmathp.el @@ -171,7 +171,8 @@ customize (customize calls it when setting the variable)." (mapconcat 'regexp-quote switches "\\|") "\\)") texmathp-toggle-regexp - (concat "\\([^\\\\\\$]\\|\\`\\)\\(" + (concat "\\([^\\$]\\|[^\\]\\(\\\\\\\\\\)*\\\\\\$\\|" + "[^\\]\\(\\\\\\\\\\)+\\|\\`\\)\\(" (mapconcat 'regexp-quote togglers "\\|") "\\)")))) @@ -286,7 +287,7 @@ See the variable `texmathp-tex-commands' about which commands are checked." (goto-char (cdr match)) (while (re-search-forward texmathp-toggle-regexp pos t) (if (setq math-on (not math-on)) - (setq sw-match (cons (match-string 2) (match-beginning 2))) + (setq sw-match (cons (match-string 4) (match-beginning 4))) (setq sw-match nil))) (and math-on sw-match (setq match sw-match))))