My Emacs/AUCTeX combination used to automatically replace a single open quote ' with an accent `, as is required by LaTeX. Many machines and .emacs files later, it doesn't do that anymore. I suppose it's an AUCTeX option, but I couldn't find it. (I thought it would be in the Tex Quote AUCTeX customization menu, but no.)

How can I make the single open quote ' automatically replaced by `?

  • I just realized that I might be misremembering; maybe my Emacs/AUCTeX combo only automatically replaced double quotes. It still does that. The question stands though. Commented Jun 22, 2013 at 15:56
  • If you really want to automatically insert a "" by pressing "'" you can put this in your .emacs: (define-key TeX-mode-map "'" "") but I'm not sure this is really a good idea. "'" is different from "", LaTeX doesn't require "" instead of "'".
    – giordano
    Commented Jun 22, 2013 at 15:58
  • Your question is a bit confusing. Emacs could obviously reolace the character but is that really what you mean? ' is an apostrophe as in it's or a single right close quote. Or perhaps you mean you want to just replace ' by ` on every other occasion so 'foo' turns in to `foo' ? Commented Jun 22, 2013 at 19:41
  • @DavidCarlisle I suppose you're right. What about replacing ' by ` whenever it's the first character of a new word? Commented Jun 22, 2013 at 19:43
  • @QuinnCulver don't you have the backtick in your keyboard layout? Anyway, if you want I can provide you a function for inserting ` by pressing ' when the preceding character isn't a letter.
    – giordano
    Commented Jun 24, 2013 at 9:48

1 Answer 1


Add the following code to your .emacs. It binds the ' key to a function which inserts an apostrophe if the preceding char is a letter, a digit, a backslash (because \` and \' give two different accents in LaTeX) or another apostrophe (to cater for LaTeX ``quotes''), a backtick otherwise.

(eval-after-load "tex"
  '(define-key TeX-mode-map "'"
     '(lambda ()
    (if (string-match "\\([[:alnum:]]\\|\\\\\\|'\\)" (string (char-before)))
        (insert "'")
      (insert  "`")))))

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .