45

How do I get a straight quote instead of curly quotes? I’m not inside verb or listing or any other special environments, and I’m not using XeLaTeX or anything—just normal LaTeX. I don’t want to change all quotes, just get the occasional straight quote. For example, I’d like a way to get something like this in the TeX:

... some examples of these glyphs are curly quotes (``''),
straight quotes ('"), and angled quotes ($'$$"$) ...

to look like this in the output:

... some examples of these glyphs are curly quotes (“”),
straight quotes ('"), and angled quotes (′″) ...

As I’m using an academic-publisher-provided template that does its own required font setup, I’m extremely wary of changing fonts or font encodings. I think the template uses the times package, and the formatting instructions say all fonts must be Type 1.

andrew
  • 2,221

5 Answers5

45

(Minor update, April 2022: loading the textcomp package to access the glyph generated by \textquotesingle is not necessary if the vintage of your TeX distribution is more recent than 2019.)

You write

I ... just [want to] get the occasional straight quote.

The typographically correct marks for "feet" and "inches" are not (single or double, resp.) straight quote marks, but angled quote marks. These may be produced in "normal LaTeX" via $'$ and $''$, resp.

Addendum, prompted by the OP's comment that interest lies only in "straight" (vertical) quotes. In addition to the "single-quote" command \textquotesingle (requires loading the textcomp package -- if the vintage of your TeX distribution is older than 2020), there's also the \textquotedbl macro, which is available as long as a font encoding other than the original TeX font encoding (aka OT1) is used.

Here, then, is a quick MWE. Note that the text font is TNR (Times New Roman). If your publisher wants to use a font encoding other than T1 -- which is what I use in the MWE -- that's no problem at all, as long as your publisher's template doesn't impose OT1...

\documentclass{article}
% access \textquotedbl:
  \usepackage[T1]{fontenc}  
% access \textquotesingle:
  \usepackage{textcomp} % not needed for TeX vintages more recent than 2019)   
% load "Times New Roman" text font:
  \usepackage{mathptmx} % (note: the "times" package is obsolete!)

\begin{document} He exclaimed, \textquotedbl Hello,
\textquotesingle Stranger\textquotesingle.\textquotedbl \end{document}

enter image description here


Second Addendum, to address a late comment by @FlashSheridan, who claims that

\textquotesingle (with or without textcomp) produces a curly closing quote, not the straight quote I need for a short C fragment.

This claim simply cannot be correct in general. As \textquotesingle is defined in the textcomp package but not the LaTeX kernel, \textquotesingle without textcomp produces an error message, not a curly closing quote. (Update April 2022: This paragraph is irrelevant if your TeX distribution is more recent than 2019.)

The following screenshots (first for Latin Modern, then for Times Roman) demonstrate conclusively that \textquotesingle does produce a straight vertical quote. In contrast, \textsf{'} does not produce a straight vertical quote -- unless, of course, some sans-serif font with straight single quote glyphs has been loaded.

enter image description here

enter image description here

Finally, the code to produce the preceding screenshots:

\documentclass[border=1pt,preview]{standalone}
\usepackage[T1]{fontenc}
\usepackage{textcomp}  % for \textquotesingle macro
\usepackage{mathptmx}  % or: lmodern
\begin{document}
Times Roman

\verb+\textquotesingle+: \textquotesingle

\verb+\textsf{'}+: \textsf{'} \end{document}

Mico
  • 506,678
  • 2
    Feet and inches was a poorly-chosen example—I should have been clearer that I actually want straight quotes. – andrew Apr 19 '12 at 16:31
  • @andrew -- thanks for this clarification. I've provided an addendum to my answer. – Mico Apr 19 '12 at 17:08
  • That sentence could as well be a nice example of the advantages of the \enquote{} command, provided by the csquotes package. – matth Apr 20 '12 at 11:09
  • @matth -- Good observation. Why don't you provide an answer in which you use the \enquote commands with parameters suitably chosen to generate straight (vertical) single and double quote marks? – Mico Apr 20 '12 at 11:16
  • @Mico Based on the OPs examples I think \enquote{} is not what the OP wants here (even if I consider it a nice solution). An answer using \enquote{} could of course help others, but then again there are many examples in the question I linked to. – matth Apr 20 '12 at 11:27
  • \textquotesingle (with or without textcomp) produces a curly closing quote, not the straight quote I need for a short C fragment. – Flash Sheridan Jun 23 '16 at 23:47
  • A more helpful (though imperfect if you look closely) answer: \textsf{`} from http://stackoverflow.com/questions/1662037/how-to-write-programming-code-containing-the-character-in-latex – Flash Sheridan Jun 23 '16 at 23:59
  • @FlashSheridan - If the textcomp package isn't loaded, \textquotesingle produces an error message unless an unusual (and so far unspecified) font package is loaded. Your claim that "\textquotesingle (with or without textcomp) produces a curly closing quote" therefore has no chance of being valid in general. – Mico Jun 24 '16 at 04:22
  • This is with a document converted by pandoc, with my only package additions makecell and hanging. Pandoc does say “% use upquote if available, for straight quotes in verbatim environments” (For my own stuff, I use \textsf{'}, but that environment is admittedly pretty weird.) – Flash Sheridan Jun 25 '16 at 18:17
  • 1
    @FlashSheridan - I've posted an addendum to demonstrate that \textquotesingle indeed produces a straight vertical quote, your claim notwithstanding. If your document doesn't produce this result, there's very likely something important in your document setup that's redefining the meaning of \textquotesingle. – Mico Jun 25 '16 at 18:47
  • Thanks, I guess it must be something imported by pandoc. (There doesn’t seem to be a way to attach a screenshot; let me know if you want it.) Since this was my only use of ', I can get by with \textsf{'}. – Flash Sheridan Jun 29 '16 at 20:22
  • \textquotesingle and \textquotedbl work (now) without any packages (under xelatex), as well as a bunch of other quote commands: \quotesinglbase, \textquotedblleft and so on, both under TS1 encoding (see https://tex.stackexchange.com/questions/7735/how-to-get-straight-quotation-marks), and TU; except two: \textquotestraightbase and \textquotestraightdblbase. – Cicada Dec 23 '19 at 03:03
  • @Cicada - Are you sure about this claim, at least for pdfLaTeX? If I try to compile \documentclass{article} \begin{document} \textquotesingle \textquotedouble \end{document} -- note that neither textcomp nor fontenc are loaded -- on my system (MacTeX2019, all add-ins up to date), I get "Undefined control sequence" messages about \textquotesingle and \textquotedouble. – Mico Dec 23 '19 at 03:49
  • @Mico, quite right: I tested just minutes ago before getting back online: pdflatex generates the error; it's OK in xelatex and lualatex. (I presumed all engines had the same 'core'). – Cicada Dec 23 '19 at 05:56
  • @Cicada - Even though LuaTeX and XeTeX have been (fairly) stable for several years by now and offer significant extra capabilities over pdfTeX, the inescapable fact is that the pdfTeX is still the engine used by the overwhelming majority of TeX&friends users. TeX users are, for one reason or another, quite conservative and slow to change their habits -- at least their typesetting habits. Sigh. – Mico Dec 23 '19 at 06:14
  • @Mico, Not enough slots. I can see now why pdflatex has to error out: it loads cmr10.pfb by default, which only has 128 slots, none of which is a single quote; textcomp.sty pulls it in via TS1 encoding, hence the need for fontenc package to manage encodings. Meanwhile, tuenc.def defines it as unicode and so xelatex and lualatex need nothing further and merrily go on their way, the system font taking care of things. (It's very cramped, the legacy font world, juggling in and out of 128-element arrays.) – Cicada Dec 23 '19 at 06:47
  • @Mico, I've discovered DeclareTextSymbol! (as used in tuenc.def) Now I can do as many \text... as needed: with \DeclareTextSymbol{\textipaturneda} \UnicodeEncodingName{"0250}, the command \textipaturneda produces ɐ. It's like being an X-eater in an X factory, where X = 'delicious'. – Cicada Dec 23 '19 at 07:32
  • Can textquotesingle little bit longer ? – alper Apr 20 '22 at 14:32
  • @alper - As the screenshot shown above (and, as I just noticed, posted almost exactly 10 years ago to the day) demonstrates, the length of the glyph produced by \textquitesingle depends crucially on font (family) that's is in use. E.g., the glyph is quite a bit longer for the Latin Modern (LM) font family than it is for the Times Roman family that's available if the mathptmx package is loaded. Which font family do you employ? – Mico Apr 20 '22 at 15:40
12

You can use \textquotesingle from the textcomp package:

\usepackage{textcomp}
....
``The lot is 25\textquotesingle wide,'' the realtor said.

There is also a \textquotedbl for double quotes in the base LaTeX package. \textquotedbl needs a \usepackage[T1]{fontenc} in the preamble, which you should be doing anyway although it can cause weird font trouble. It will be fine with times though.

andrew
  • 2,221
  • 4
    "The weird font trouble" can be easily solved by installing the cm-super fonts (or by switching to the lmodern fonts). – Ulrike Fischer Apr 19 '12 at 10:07
  • Unfortunately external factors require that the document must be in times using only Type 1 fonts so I don’t think I can do that :/ – andrew Apr 19 '12 at 16:32
  • 3
    If you use times you won't have the "weird font trouble". Also installing a font package doesn't force to use it in your document. But if your document needs it it will be there. – Ulrike Fischer Apr 19 '12 at 16:47
3

For LuaLaTeX users, this can be done very easily in the package luaquotes! (Disclaimer: I am the developer of the package)

\documentclass{standalone}
\usepackage{luaquotes}
\usepackage{fontspec}
\setmainfont{Libertinus Serif}  
\begin{document}
\dumbquotes
\addfontfeature{RawFeature=+qtbye}
    "I heard John say, 'Hi'. It was nice"
\end{document}

][2]

ezgranet
  • 564
1
\char13

Pakin writes:

Outside of verbatim, you can use \char18 and \char13 to get the modified quote characters. (The former is actually a grave accent.)

Scott Pakin, "ASCII and Latin 1 quick reference" in The Comprehensive LATEX Symbol List.

-2

If the single quote or your double quote changes automatically try putting them inside textnormal like: \textnormal{"Hello"}