36

I recently discovered that LaTeX has a different symbol for opening (``) and closing ('') quotation marks. I have been incorrectly writing "abc". How do I convert all the quotations to become ``abc'' instead? Doing it manually will take forever as I have a lot of quotations.

  • 3
    You could just use sed for this (sed is awesome). It does require some escaping on the command line, since you are trying to replace quotes. I can't put it in here, since it contains backticks. So a link will have to do. – Roelof Spijker Apr 04 '12 at 12:28
  • On an unrelated note, a lot of editors will automatically replace " with the correct quotation form when you type the character. I know for a fact kile does this, and I believe AUCTeX does so as well. – Roelof Spijker Apr 04 '12 at 12:31
  • 1
    See also http://tex.stackexchange.com/questions/38985/replace-quotes-with-quotes – Joseph Wright Apr 04 '12 at 13:22
  • @RoelofSpijker There are some advantages in NOT using the auto-replace-feature: http://tex.stackexchange.com/questions/39285/whats-the-advantage-of-using-csquotes-over-using-an-editors-auto-replacement-f – matth Apr 08 '12 at 20:14
  • @matth: I completely agree. In my academic writings I (pretty much) never use quotes. The only time I use them is when passing a literal string to the pgf math engine and in that case I need actual quotes, not the converted ones. Which mostly ends up in me typing \" and then removing the \. This doesn't happen often enough for me to disable the autoreplace though. I know what I want in what case and how to obtain it. If you are using mostly quotes as in quotations it's an option though :) – Roelof Spijker Apr 08 '12 at 23:54

4 Answers4

41

An alternative to quotes is csquotes from 2011, while quotes is from 1997 …

\documentclass[english]{article}

\usepackage{babel}
\usepackage{csquotes}
\MakeOuterQuote{"}

\begin{document}
Hello "World"!
\end{document}
Tobi
  • 56,353
22

The package csquotes has many more goodies than the one mentioned. If you use the command \enquote{. . .}, you can nest several levels of quotations, while LaTeX preserves the correct couples of signs. You can even set localization preferences in order to use the proper signs for a language.

For instance, \enquote{\enquote{This is a quote within a quote}} will be rendered as:

“‘This is a quote within a quote’”

(with a thin space in between the contiguous signs).

But if you load the csquotes package thus (as I usually do):

\usepackage[autostyle=false, style=british]{csquotes}

the previous code will be rendered thus:

‘“This is a quote within a quote”’

See the documentation of the package for further details (texdoc csquotes).

matth
  • 12,381
NVaughan
  • 8,175
11

There is a package for this: quotes. With this package, "text" is typeset correctly as ``text''.

doncherry
  • 54,637
Boris
  • 38,129
8

Edit 2 solution suggested by Boris seems to be the easier way.

Depending on which editor you use you can perform a search an replace. You would be searching for

_" 

(replace the underscore with a white space, its just there to make my point) and then replace it by

_``

again, the underscore stands for a white space.

Edit

As David Carlisle pointed out that you should also change the right quote to '' so you get the proper right quote.

However there you have to account for the following characters after the right quote. I know no better way than trying to think of all possibilities (I can think of 4 that are likely)

"_ %your quote is followed by a white space
". %your quote is followed by a period
", %your quote is followed by a comma
"! %your quote is followed by an exclamation mark

then replace each of them with their respective version

''_

etc.

Edit 3 MWE with quotes package

% !TEX encoding = UTF-8 Unicode

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{quotes}

\begin{document}
\noindent "test" \\
``test''
\end{document}
David Carlisle
  • 757,742
Philipp
  • 5,078
  • 10
  • 30
  • 32
  • 4
    Note that in addition to changing the left quote to ` you should change the right one to '' it is only by accident, and only in some encodings, that the input of " produces the right double quote ligature. – David Carlisle Apr 04 '12 at 12:27
  • I tried:\usepackage{quotes} ...... "MyWord" .... but it still making opening curly quote back-ward direction I am using Mac OS X, Standard US english Key-board. I have written full document using TexShop. An did not use underscore...so that I do find and replace as suggested by @Philipp....... Any help please? – khademul Apr 04 '12 at 13:29
  • I tried a MWE with the quotes package and it works fine. I added the MWE to my answer at the end. – Philipp Apr 04 '12 at 14:53