5

When writing LaTeX documents in Emacs, it usually automatically replaces quotation marks " by `` or '', as it should. But sometimes, it incorrectly replaces by "` and "' instead. I am observing this in Emacs 23.4 supplied as version 23.4+1-4ubuntu1 in Ubuntu 13.04.

It happens in the below example:

\documentclass[danish]{article}
\usepackage{babel}
\begin{document}
This is a "`test"'.
\end{document}

My guess is that babel and the language option danish is causing this together with AUCTeX. If I change it to english and reset AUCTeX, the problem disappears. If I change it back to danish and reset AUCTeX it re-appears. How can I fix this?

Thomas Arildsen
  • 929
  • 2
  • 9
  • 17

1 Answers1

2

AUCTeX has a special support for many languages, for example it can help inserting quotes. For more information see the AUCTeX manual.

If you don't like the default style of quotes inserted by AUCTeX for a specific language, you can override it customizing the TeX-quote-language-alist variable. To do that add this to your .emacs:

(setq TeX-quote-language-alist '(("danish" "``" "''" t)))

In this way pressing " button twice you will get `` or '' according to context. Instead, if you want to insert `` and '' pressing " button just once, add the following code to your .emacs:

(add-hook 'TeX-language-dk-hook
      (lambda ()
        (setq TeX-quote-language `("danish" "``" "''" ,TeX-quote-after-quote))))
giordano
  • 136
  • 6
  • I am in doubt what the official correct Danish quote marks are, but they are certainly not "` and "'. I will have to figure that out. – Thomas Arildsen Jul 02 '13 at 12:58
  • I'm not a danish speaker, I can't help you in this regard. Change the variable according to your need, I just showed you how to do that `;-)` – giordano Jul 02 '13 at 13:00
  • Which looks exactly like what I need. Testing the above, I see that your command causes the quote marks to become ". Is that intended? I was guessing that it would cause them to become `` and '', but I am quite lisp-illiterate... BTW, I am a native Dane, so I guess I should know the correct marks :o) – Thomas Arildsen Jul 02 '13 at 13:03
  • 1
    Press `"` twice. – giordano Jul 02 '13 at 13:04
  • 1
    @ThomasArildsen I expanded the answer, there is a solution to get opening and closing quotes pressing `"` once. – giordano Jul 02 '13 at 13:09