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)))