10

I'm using the csquotes package with the modifications recommended by this answer, to detect quotation marks in my text (pasted from Microsoft Word) and make them look good in the output.

Is there any way to have it also detect single quotes, so that they are oriented the correct way and not treated as apostrophes, without messing up the existing apostrophes? (I don't want to have to manually find all of the quote-within-quotes and replace ' with `.)

\documentclass{article}

\usepackage{csquotes}
\usepackage[american]{babel}
\DeclareQuoteStyle[american]{english}% verified
  {\textquotedblleft}
  [\textquotedblleft]
  {\textquotedblright}
  [0.05em]
  {\textquoteleft}
  {\textquoteright}
\MakeOuterQuote{"}

\begin{document}
I say: "These quotes look nice, but 'if I quote someone else within a quote like this,'
or 'like this,' they don't."
\end{document}

quote screenshot

  • 3
    You can't make the ' character an active quote in csquotes like you did for " since it is a reserved character (see §10.3 of the documentation). Since your text is coming from MSWord, if you use a UTF8 encoding, you can use Word's smart quotes facility to make the quotes into the correct characters and then just use them directly. – Alan Munn Oct 10 '13 at 3:08
  • @AlanMunn Thank you! Two follow-up questions: 1) How do I use the UTF8 encoding? 2) Even if I manually use the ` character to start a single quote, it doesn't look great since it blends into the letter (if it's capital)--is there a better character to use? – jamaicanworm Oct 10 '13 at 3:11
  • 1
    On the LaTeX side: \usepackage[utf8]{inputenc}. On the Word side, I remember it just automatically converting quotation marks to the "smart" ones whether you liked it or not. Isn't that still true? – jon Oct 10 '13 at 3:33
  • 2
    @jamaicanworm You can use \usepackage[utf8]{inputenc} in your input file (and save it as UTF8 in your editor). Or save it as UTF8 and use XeLaTeX or LuaLaTeX. See Preparing a text for conversation to LaTeX: How to convert "ejective stops" in TIPA? for an answer like that. But the idea is that you go back to your Word document source and change all the quotes to 'smart' quotes and then paste the fixed text directly into your LaTeX source. – Alan Munn Oct 10 '13 at 3:33
  • @AlanMunn Feel free to post that as an answer, seems like other people could benefit as well. I posted my second follow-up as a new question at tex.stackexchange.com/q/137275/9757 – jamaicanworm Oct 10 '13 at 14:57
7

Although the csquotes package allows you to define certain characters as "active" quotes, as your sample document does for the " character, the single quote character cannot be so used, since it is a reserved character in TeX.

Since you mention that you are using text from an MSWord document, a better solution in this case would be to encode your source file as UTF-8 and either use the inputenc package (if you are using pdfLaTeX) or a UTF-8 aware engine (XeLaTeX or LuaLaTeX) to compile your document. In this way you can use the "smart" quote characters ,, , and directly in your source document. MSWord is quite good at automatically converting quotes correctly. If your document doesn't currently use the smart quotes, you can turn that on and then do a global replace for both ' and " and all the quotes will then be correctly changed.

Source with these quotes can then be used in your LaTeX document. In this case, you don't need to use the csquotes package at all (although you can, still if you have a mixture of quotation marks in the source.)

Using pdfLaTeX

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
I say: “These quotes look nice, but ‘if I quote someone else within a quote like
this,’ or ‘like this,’ they don’t.”
\end{document}

Using XeLaTeX or LuaLaTeX

\documentclass{article}
\usepackage{fontspec}
\begin{document}
I say: “These quotes look nice, but ‘if I quote someone else within a quote like
this,’ or ‘like this,’ they don’t.”
\end{document}

output of code

  • 3
    This is a excellent, detailed answer, just to add that if one has a trivial problem where one merely wants single marks (as I did), one may use \enquote*{Blah}. – Raj Jul 25 '16 at 15:28

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.