# Quotation marks

I have problem with my Latex document, the following code:

\documentclass{article}
\begin{document}
This is "test". And another 'test'
\end{document}


results with this:

Is it possible to make something that will affect the whole document so that the quotation marks looks like this:

I know I can use \lq and \rq commands, but I have a huge document and I would really like to avoid going through it all. If there is some kind of directive that would affect the wole document to use opening and closing quotations?

• just replace the starting with test'' and test' respectively. – Raaja Aug 16 '18 at 10:09
• There is one problem: LaTeX does not know which " opens and which closes, hence you need to provide at least that piece of information (and as Raaja mentioned, using the TeX quotes would be an easy way to do so). – TeXnician Aug 16 '18 at 10:11
• Nonetheless, an editor solution will be easier and preferable in all ways to a LaTeX solution. You should be able to write a macro with most editors to handle 2 at a time, and thus not get out of sequence (except for lone apostrophes). – Steven B. Segletes Aug 16 '18 at 10:20
• Then again, you could just set your document in \ttfamily...just kidding. – Steven B. Segletes Aug 16 '18 at 10:23
• You have tagged the question with csquotes and that package can help a lot. Try \usepackage{csquotes} \MakeOuterQuote{"}, though I usually prefer \enquote{foo} to "foo" with \MakeOuterQuote{"}. – moewe Aug 16 '18 at 10:23

You can try for the double quotes the csquotes package:

\documentclass{article}
\usepackage{csquotes}

\MakeOuterQuote{"}
\begin{document}
This is "test".

\end{document}


But it will only work if there are always pairs of double quotes, if they are correctly nested with respect to tex groups, and if you don't use quotes for other purposes (e.g. to quote spaces in a file name). In large documents it almost never runs without error from the beginning.

For single quotes there is nothing similar. csquotes will not allow you (for good reasons) to set ' as a quote sign. The main problem here is that quite probably you are using it as apostroph in various places too -- see above the don't in my text.

I earlier joked about just setting the document in \ttfamily. But that raised the possibility of making " active and just setting that glyph in the symmetric \texttt style.

EDITED to also work for single quote while at the same time preserving its behavior as a superscript prime in math mode.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\catcode'=\active %
\catcode"=\active %
\makeatletter
\def'{\ifmmode\def\qnxt{\catcode'=12 ^\bgroup\prim@s}%
\else\def\qnxt{\textquotesingle}\fi\qnxt}
\makeatother
\def"{\textquotedbl}
\begin{document}
This is "test". And another 'test'.

$x'$ and $x''$ and $x'''$.

And this is a final 'test'.
\end{document}


ORIGINAL APPROACH

\documentclass{article}
\let\svq"
\catcode"=\active
\def"{\texttt{\svq}}
\begin{document}
This is a "test" of active "quotes."
\end{document}


• It's quite ugly isn't it? :P But a very very nice work around +1 :) – Au101 Aug 16 '18 at 13:09
• @Au101 The same cannot be easily done for the single quote because of its use as a superscript prime in math mode. – Steven B. Segletes Aug 16 '18 at 13:51
• @Au101...but I somehow managed to do it anyway. – Steven B. Segletes Aug 16 '18 at 14:03
• Why not just use the standard  and ‘’ for double quotes and  and ‘ for single quotes? – Herb Schulz Aug 16 '18 at 15:26
• @HerbSchulz Because for any given instance, I don't know whether it is the left or the right one. Thus, the "unisex" quotes seems the only alternative. As I told the OP in comments, best solution is for him to edit his source and fix it. – Steven B. Segletes Aug 16 '18 at 15:33