# Automatically convert quotations in the form of “abc” to become abc"

I did not know that latex had different symbol for opening and closing quotation marks. I've used it like "abc" every where and just realised that I really should have used abc". Is there anyway I can convert all the quotations to become like abc"? Doing it manually will take forever as I have a lot of quotations.

-
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 4 '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 4 '12 at 12:31
–  Joseph Wright Apr 4 '12 at 13:22
@RoelofSpijker There are some advantages in NOT using the auto-replace-feature: tex.stackexchange.com/questions/39285/… –  matth Apr 8 '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 8 '12 at 23:54
add comment

## 4 Answers

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}

-
add comment

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}

-
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 4 '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 4 '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 4 '12 at 14:53
add comment

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

-
The package quotes is very simplistic. I'd recommend csquotes instead. –  egreg Apr 8 '12 at 15:39
add comment

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`).

-
add comment