Why can't LaTeX smartly match the double quote?

The standard logic for inserting smart quotes in place of dumb quotes is as follows:

  1. If there is a space character before the quote, it is an opening quote;
  2. Otherwise, it is a closing quote.

However, this is problematic in the case of the apostrophe. Consider the (English) transcription of the dropped 'h' in 'hello', which is stereotypically attributed to the Cockney accent:

’ello

According to the rules above, this would be typeset as an opening single quote, rather than as an apostrophe (which is equivalent to the closing single quote).

Although I am not familiar with the language, I gather that there are many examples of this in French as well.

There is no algorithm for determining when such an apostrophe is intended, rather than an opening quote, and so incorporating this feature would require an exception list, as in hyphenation. However, since the use of apostrophes for indicating elisions (as in the example above) is significantly increased in dialectal speech (at least in English), an exception list is not an appropriate solution to this problem.

So it is not appropriate for the compiler to attempt to convert dumb single quotes into smart single quotes. Although your question refers to double quotes, single quotes and double quotes really ought to work the same way, since they are so closely related.


Short answer: You said it: "while typing". LaTeX code can be typed with any text editor and even any word processors, so this is a problem of the editor, not the LaTeX code, that it must be unambiguous. Use a editor with this feature, as TeXWorks.

Long answer: Since pdflatex, xetex, etc work with an already typed code, a LaTeX solution would require a posteriori the interpretation of your thoughts in that you have typed, a needless complication in IMHO. For instance, what to do with this simple code?:

\documentclass{article}
\begin{document}
2", 5" and 7"
\end{document}

May be you want here 2``, 5'' and 7", or may be 2", 5`` and 7'' or simply 2", 5" and 7" exactly as you typed? What to do if this interpretation is wrong? It will be a pain if you need to re-edit to be more specific about what you want really.

Instead, if the interpretation of your thoughts is done by the editor, misinterpretation is less painfull. Following the example, if you typed in TeXWorks 2", 5" and 7" and "more" will be typed 2'' and 5'' and 7'' and ``more'' (note that each " are now two characters) that probably is what you want, but in other case you can change easily in a second.

Anyway, this feature is not painless, since this force that " (single character) must be obtained with Ctrl+Shift+2 instead of the usual Shift+2.


I have difficulties understanding what you want to ask. I recognize 3 distinct points here:

(1) Why doesn't Latex automatically change " + " to smart quotes + ?

(2) Why does LaTeX use `` + '' for quoting?

(3) It's annoying that you can't automatically replace dumb quotes " + " with smart quotes + in LaTeX when you copy and paste a text with dumb quotes into a text editor.

The answer to (1) is that LaTeX uses (2). I can't see how that's any better or worse than using " + ". Nevertheless, at least some text editors (e.g. Texworks) will automatically replace " + " with the conventional LaTeX sequences `` + ''.

For (3), I guess that's annoying, but I don't know of any other word processor that automatically replaces " + " with smart quotes + when you copy a text with dumb quotes either. MS Word certainly does not.

Tags:

Punctuation