So basically, for reasons unknown we don't use regular LaTeX style quotes at my company, instead just using regular double quotes. However, tex-mode in emacs automatically substitutes the " key for ``''. I can't find any way of disabling this.

I've tried setting tex-open-quote and tex-close-quote to ", which works to some degree, but when inserting quotes inside a \verb!!, it still substitutes the first ! with `'' for some unknown reason.

I'm using Doom-Emacs, but I doubt this has anything to do with the functionality.

Is there any way of completely disabling this functionality, or at least unmapping the " key from tex-insert-quote?

  • Have you tried disabling it in pure Emacs without init file? (emacs -q) – user12563 Aug 20 '19 at 15:10
  • Typing " twice should result in a classical ". – StarBug Aug 20 '19 at 15:44
  • Firstly, that doesn't really solve my problem, as I don't want to have to double tap quotes every time. Secondly, that doesn't even work in my emacs. There's likely something broken in either my config or in doom-emacs itself. – ryan27968 Aug 20 '19 at 15:47
  • Just to clarify, are you using AUC-Tex? – StarBug Aug 20 '19 at 15:57
  • I don't believe so. I haven't installed anything additional, I'm just using the defaults from doom-emacs. C-h m says my major mode is tex-mode and I don't spot any other tex-related minor modes. – ryan27968 Aug 20 '19 at 16:02

This appears to be smartparens doing (another package that Doom uses). Even if you unmap the double quote key like so:

(map! :after tex
      :map TeX-mode-map
      "\"" nil)

;; this is equivalent to
(with-eval-after-load 'tex
  (define-key TeX-mode-map "\"" nil))

Smartparens' defaults will still kick in when you type a double quote. You can disable this troublesome rule with:

(after! smartparens-latex
  (sp-local-pair '(tex-mode plain-tex-mode latex-mode LaTeX-mode)
                  "``" "''" :actions :rem))

;; This is equivalent to
(with-eval-after-load 'smartparens-latex
  (sp-local-pair '(tex-mode plain-tex-mode latex-mode LaTeX-mode)
                  "``" "''" :actions :rem))

I'll look into merging this into the lang/latex module upstream.

| improve this answer | |
  • Thanks, this got me on the right track, although the maps that you suggested don't quite work. I've tweaked a bit and gotten it working. My working fix in the related github issue: github.com/hlissner/doom-emacs/issues/1688 If you fix your solution, I'll accept your answer as it narrowed down the true culprit. – ryan27968 Aug 22 '19 at 8:54

You can rebind the " key in tex-mode with the following:

(eval-after-load "tex-mode"
  (define-key tex-mode-map "\"" 'self-insert-command))

self-insert-command turns " back into a normal key, it will just insert itself when you press it. If you want it to do anything else, use a different function here.

| improve this answer | |
  • No luck. For some reason your binding command did not work, although I was able to get the binding to work using some doom-emacs helper macros. Either way, it still inserts the latex funky quotes. I've done C-h " while in insert mode and can confirm it has indeed mapped correctly to self-insert-command, yet it still replaces the quotes. – ryan27968 Aug 20 '19 at 15:28
  • Hmm... I've just tried your remap with emacs -q as suggested by @DoMiNeLa10 and it does work correctly. It seems doom-emacs must be interfering somehow. Will consult on the doom-emacs github. – ryan27968 Aug 20 '19 at 15:38

In case you are using AUCTex, you can use

(setq TeX-quote-after-quote t)

From the manual: If TeX-quote-after-quote is non-nil, typing " will insert a literal double quote.

| improve this answer | |
  • Yeah I don't have AUC-Tex installed so it's definitely not that... – ryan27968 Aug 20 '19 at 16:03
  • @ryan27968: I recommend you try out AUCTex. It is really good. – StarBug Aug 20 '19 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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