When type " in AucTeX, either `` or '' is typed. How do I do similar action with single quotes? Typing ' won't give me ` or '.

EDIT I'm not asking about the double quotes---I agree with what double quotes did and I just want to show that single quotes do not behave the same as double quotes, but I want single quotes to behave the same as double quotes.

My babel is English.

  • Which is the language option passed to babel? AUCTeX treaties quotes in a special way in some cases. If I remember correctly, double quotes " can't be used in a basic LaTeX document, you'd need to replace them with ``...'' anyway, in that case. Reading the manual is always useful, before asking a question.
    – giordano
    Jan 16, 2016 at 8:12
  • Surely, " can be used in basic LaTeX. It produces the same result as '', which results in ” in the document. Because this is of limited usefulness, some babel packages will use " for entirely different purposes, however. (These days, I use utf8 for nearly all my LaTeX documents, and I type ‘single’ and “double” quotes directly.) Jan 16, 2016 at 20:06
  • @giordano See my edit.
    – xuhdev
    Jan 16, 2016 at 20:29
  • @HaraldHanche-Olsen you're right. I remembered that there was some problems connected with using ", but I couldn't check when I wrote the above comment. You're right: the problem is that you always get the closing double quotes.
    – giordano
    Jan 16, 2016 at 23:15
  • Single quote handling would have to be (slightly) more clever than double quote handling, because single quotes should be inserted verbatim inside formulas. Jan 17, 2016 at 11:22

1 Answer 1


Adapted from TeX-insert-quote:

(defun mg-TeX-insert-single-quote (force)
  "Insert the appropriate quotation marks for TeX.
Inserts ` or ' depending on the context.  With prefix argument
FORCE, always inserts ' characters."
  (interactive "*P")
  (if (or force
      ;; Do not insert TeX quotes in verbatim, math or comment constructs.
      (and (fboundp 'font-latex-faces-present-p)
           (font-latex-faces-present-p '(font-latex-verbatim-face
           (font-latex-faces-present-p '(font-latex-verbatim-face
                       (1- (point))))
      (and (TeX-in-comment) (not (eq major-mode 'doctex-mode))))
      (self-insert-command (prefix-numeric-value force))
    (let* ((open-quote "`")
       (close-quote "'"))
      (insert (cond ((bobp)
            ((= (preceding-char) (string-to-char TeX-esc))
            ((= (preceding-char) ?\")
               (forward-char (- (length open-quote)))
               (looking-at (regexp-quote open-quote)))
             (delete-char (- (length open-quote)))
               (forward-char (- (length close-quote)))
               (looking-at (regexp-quote close-quote)))
             (delete-char (- (length close-quote)))
               (forward-char -1)
               (looking-at "[ \t\n]\\|\\s("))

(eval-after-load "tex"
  '(define-key LaTeX-mode-map (kbd "'") 'mg-TeX-insert-single-quote))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.