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
.
\documentclass{article}\usepackage{csquotes}\MakeOuterQuote{"}\begin{document}"Hello"\end{document}
(this will probably not work withbabel
and a language that uses"
as shorthand...)csquotes
package as suggested by @cgnieder. It does exactly this and has the additional advantage that you could easily change the actual quote style (single, double, french quotes...) in a central position.