Hi Greg,
Greg Minshall <[email protected]> writes:
> i'd like to plead the case of allowing the user to suppress dollar-sign
> behavior (or, force dollar-signs to mean math-mode).
I'm attaching a patch that introduces `org-latex-escape-chars' which
would allow you to bind it to something different for each buffer --
e.g., without the dollar sign.
Nicolas, let me know if this looks okay for you.
Thanks,
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9d5b5c5..805eeb7 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -510,6 +510,14 @@ default we use here encompasses both."
:group 'org-export-latex
:type 'string)
+(defcustom org-latex-escape-chars "%$#&{}~^_"
+ "Characters to escape.
+Each character in this string will be escaped.
+E.g., _ will be escaped into \_."
+ :group 'org-export-latex
+ :version "24.3"
+ :type 'string)
+
;;;; Tables
@@ -1942,8 +1950,11 @@ TEXT is the string to transcode. INFO is a plist holding
contextual information."
(let ((specialp (plist-get info :with-special-strings))
(output text))
- ;; Protect %, #, &, $, ~, ^, _, { and }.
- (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}~^_]\\)" output)
+ ;; Protect characters from `org-latex-escape-chars', i.e.,
+ ;; %, #, &, $, ~, ^, _, { and } by default.
+ (while (string-match
+ (concat "\\([^\\]\\|^\\)\\([" org-latex-escape-chars "]\\)")
+ output)
(setq output
(replace-match
(format "\\%s" (match-string 2 output)) nil t output 2)))
--
Bastien