emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Aaron Ecay <aaronecay@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] Properly escape ~ for LaTeX export
Date: Sun, 31 Mar 2013 22:21:09 -0400	[thread overview]
Message-ID: <1364782869-2049-1-git-send-email-aaronecay@gmail.com> (raw)

* lisp/ox-latex.el:
(org-latex-plain-text): Properly escape ~ for LaTeX export

In LaTeX, \~ gives a tilde diacritic (as in ã).  \textasciitilde{} is
the correct escape for a tilde.
---
 lisp/ox-latex.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 8727adc..af7e11e 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2031,8 +2031,8 @@ 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 %, #, &, $, ^, _,  { and }.
+    (while (string-match "\\([^\\]\\|^\\)\\([%$#&{}^_]\\)" output)
       (setq output
 	    (replace-match
 	     (format "\\%s" (match-string 2 output)) nil t output 2)))
@@ -2043,6 +2043,10 @@ contextual information."
 	    (replace-regexp-in-string
 	     (format "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%s]\\|$\\)" symbols)
 	     "$\\backslash$" output nil t 1)))
+    ;; Protect ~
+    (while (string-match "\\([^\\]\\|^\\)\\(~\\)" output)
+      (setq output
+            (replace-match "\\textasciitilde{}" nil t output 2)))
     ;; Activate smart quotes.  Be sure to provide original TEXT string
     ;; since OUTPUT may have been modified.
     (when (plist-get info :with-smart-quotes)
-- 
1.8.2

             reply	other threads:[~2013-04-01  2:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01  2:21 Aaron Ecay [this message]
2013-04-01  7:56 ` [PATCH] Properly escape ~ for LaTeX export Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364782869-2049-1-git-send-email-aaronecay@gmail.com \
    --to=aaronecay@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).