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?

6
  • 3
    That's gonna be a hard one if you can't pin down the elusive "sometimes".
    – terdon
    Jun 25, 2013 at 13:03
  • Which languages are you loading with babel package?
    – giordano
    Jun 28, 2013 at 17:17
  • @giordano I will get back to you on this as soon as I encounter a document again that causes this. Jul 2, 2013 at 11:11
  • @ThomasArildsen another question: do you use AUCTeX or default Emacs TeX mode?
    – giordano
    Jul 2, 2013 at 11:14
  • @giordano I am using AUCTeX. Jul 2, 2013 at 11:31

1 Answer 1

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))))
5
  • 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. Jul 2, 2013 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 2, 2013 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) Jul 2, 2013 at 13:03
  • 1
    Press " twice.
    – giordano
    Jul 2, 2013 at 13:04
  • 1
    @ThomasArildsen I expanded the answer, there is a solution to get opening and closing quotes pressing " once.
    – giordano
    Jul 2, 2013 at 13:09

You must log in to answer this question.

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