3

I have a document in which everything is quoted in the form:

``quote''

How do I make them appear in the output document as

“quote„

thanks

  • 2
    You can't: \csquotes has its own commands and doesn't act on explicit quotes. – egreg Oct 10 '13 at 15:46
  • @Geremia -- If no one comes up with a better solution, you may try \def\lq{\raisebox{-6pt}{''}} and then use an editor to replace all right '' with \lq. Not fully automatic yet, this may point a direction to a solution. – Jesse Oct 11 '13 at 7:45
  • 1
    @Jesse If you do something like that, you can drop some crazy \raisebox and use \textquotedblbase. Or skip \lq entirely and use csquotes package. – yo' Mar 17 '14 at 10:42
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Oct 24 '16 at 19:06
6

Here's something that works for me. It is based on making the right single quote an active character in TeX. I must admit I have no confidence that this doesn't break something else, especially in the light of the negative comment by @egreg to the original question.

Let's start with an example that contains a number of quotations. The first line shows how we would like double quotes to appear.

\documentclass[12pt]{article}    
\usepackage[T1]{fontenc}

\begin{document}
This is the \textquotedblleft{}quote\quotedblbase{} that I'd want.

Let's play with some ``double quotes'' and
some ``more double quotes''            and yet ``some more''
and then with some `single quotes' and
some `more single quotes'          and yet `some more'
and see what happens.
\end{document}

before

Now, by adding the following lines to the preamble:

\makeatletter
\catcode`'=\active
\def'{\futurelet\@rqpeek\@rqhack}
\def\@rqhack{\ifx\@rqpeek'\expandafter\dbl@rq\else\rq\fi}
\def\dbl@rq'{\quotedblbase}
\makeatother

you can get what you want.

after


EDIT: After egreg's comment about this tweak breaking math that contains primes, like $f'(x)$, I'm providing a fix and concluding with a brief explanation and a disclaimer.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

\makeatletter
\catcode`\'=\active
\def'{\ifmmode\expandafter\active@math@prime\else\expandafter\@rqtext\fi}
\def\@rqtext{\futurelet\@rqpeek\@rqhack}
\def\@rqhack{\ifx\@rqpeek'\expandafter\dbl@rq\else\rq\fi}
\def\dbl@rq'{\quotedblbase}
\def\pr@m@s{%
  \ifx'\@let@token
    \expandafter\pr@@@s
  \else
    \ifx^\@let@token
      \expandafter\expandafter\expandafter\pr@@@t
    \else
      \egroup
    \fi
  \fi}
\makeatother

\begin{document}
This is the \textquotedblleft{}quote\quotedblbase{} that I'd want.

Let's play with some ``double quotes'' and
some ``more double quotes''            and yet ``some more''
and then with some `single quotes' and
some `more single quotes'          and yet `some more'
and see what happens.

Let's see some math too:
if $f(x) = x^2$ then $f'(x) = 2x$ and
$$f''(x) = 2$$

And some more `single' and ``double'' quotes.
\end{document}

math too

The fix comes in two parts. First the active quote has to check whether it's found in math mode or text mode. Second, the internal macro \pr@m@s (handling successive primes in math mode) has to be repeated here (verbatim from latex.ltx) because it checks whether the next character is ' and now it has to check for an active '.

Disclaimer: Making the single right quote an active character is expected to break everything that already treats it as an active character. Examples that cross my mind are: the babel package (some languages with accents), various math packages like euler, various verbatim-text packages like the alltt. But there are also packages, like xspace which (temporarily) set the \catcode of \' to 13. I've tested euler, alltt and xspace and they seem to work fine with this. All this said, you have been warned. If a package breaks with this, I don't expect the fix to be obvious...

  • 1
    Of course this breaks math $f'(x)$, which is one of the drawbacks. – egreg Oct 12 '13 at 0:13
  • @egreg: If that's the only problem, I guess it can be fixed by making ' non-active when in math mode. – nickie Oct 12 '13 at 0:17
  • @egreg: math was easy, I'm updating the answer. I'll explain what else is expected to break and I'll stop here. – nickie Oct 12 '13 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.