# How to get straight quotation marks?

How do I get straight quotation marks, i.e., " and ' in TeX? (No, \verb changes the font and this is unacceptable.)

 I forgot to mention that I’m using XeLaTeX, and fontspec is a necessity. The first two proposed answers did work, without fontspec.

-
It seems you want to include code snippet in your latex document. If my prediction is correct, the following might be what you are looking for: Double quotes with monospaced font and LuaLaTeX –  xport Dec 25 '10 at 19:09
@xport But your prediction was not correct, … sorry. –  JC Chu Dec 25 '10 at 19:48

I found this post in the last few days while searching for an answer to the same problem. I'm also using XeLaTeX, and also need fontspec, so I feel your pain. I tried all kinds of things, which I won't list here.

Here's the solution I came up with:

As you discovered, the Mapping=tex-text option is what is changing the straight quotes to curly (no matter what). As you also saw, removing it results in no curly quotes anywhere. That's no good either.

The standard XeLaTeX template in TeXShop (I've excluded the sans and mono font declarations) has:

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}


I decided to define a new font, using the same typeface as the roman font, but not include any mapping.

\newfontfamily{\S}{Hoefler Text}


As a final step, the \defaultfontfeatures{Mapping=tex-text} line must be deleted or commented out. If not, it adds mapping to all font declarations. I suppose that's meant to be helpful in case one forgets it, but in this case, it's holding us back. Since \setromanfont above already declared its mapping, removing it as a default feature won't alter the appearance of normal typing, giving you access to curly quotes.

The altered preamble section will then be:

\usepackage{fontspec,xltxtra,xunicode}
%\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Hoefler Text}
\newfontfamily{\S}{Hoefler Text}


When you need straight quotes, put them within the custom font call. Since there is no mapping, you will get finally them.

The antique'' table is 5{\S '}6{\S "} long.


I set custom commands to make writing easier.

\newcommand{\inch}{{\S "}}
\newcommand{\feet}{{\S '}}


This allows me to write:

The antique'' table is 5\feet 6\inch\ long.


I hope this helps. I was creating a 100+ page document, and needed both curly and straight quotes frequently. This is the only thing I've tried that works, period. If there is a more elegant way (in XeLaTeX with fontspec), I'd love to learn it. I've only been using TeX/XeLaTeX for 2-3 months, so I'm kind of a newbie.

-
Thanks for your advice which works. BTW, I tried to keep \defaultfontfeatures{Mapping=tex-text} and define the font family \S with \newfontfamily{\S}[Mapping=tex-ansi]{...}, --- this also works. –  JC Chu Feb 18 '11 at 4:11
Good to know! Thanks. –  Michael Feb 18 '11 at 4:14
from the fontspec documentation: Using the Mapping=tex-text is equivalent to writing Ligatures=TeX. The use of the latter syntax is recommended for better compatibility with LuaTEX documents. In addition to ligatures, this will emulate TeX's behaviour for ASCII input of curly quotes and punctuation. If you do NOT want this additional emulation, just use Ligatures=Common instead. –  matth May 3 '12 at 16:02

Using \usepackage[T1]{fontenc} is @TH's idea. I just add \usepackage{upquote} to provide a single straight quote using \textquotesingle.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{upquote}

\begin{document}

\textquotesingle single straight quote\textquotesingle\
and "double straight quote"

\vspace{5mm}

single curly quote' and double curly quote''
\end{document}

-
This works well if <i>fontspec</i> is not used, but it’s necessary for me. (Sorry I forgot to mention I’m using XeLaTeX…) –  JC Chu Dec 25 '10 at 19:43
Use \textquotesingle provided by \usepackage{upquote}, and what happens? –  xport Dec 25 '10 at 19:52
It works, provided I don’t use \setmainfont[Mapping=tex-text]{...}. If I do not specify the mapping, curly quotes will be unavailable; if I do, \textquotesingle becomes curly too. –  JC Chu Dec 25 '10 at 20:20

The LaTeX encoding specific commands for quotes of various sorts are listed below. The first group are defined in (at least) T1 encoding and the second group are defined in (at least) TS1 encoding. If in addition to loading the encodings (via \usepackage[TS1,T1]{fontenc} the TS1 encoding is loaded via \usepackage{textcomp} then in addition to declaring the TS1 quotes for TS1 encoding, this is made the default encoding, so if you use \textquotesingle in an encoding for which the straight quote is not declared then LaTeX will switch to TS1 encoding just for this character.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{textcomp}

\def\showq#1{\texttt{\string#1}&abc#1xyz\\}

\begin{document}

\begin{tabular}{ll}
\multicolumn{2}{c}{T1}\\
\showq\quotedblbase
\showq\quotesinglbase
\showq\textquotedblleft
\showq\textquotedblright
\showq\textquotedbl
\showq\textquoteleft
\showq\textquoteright
\multicolumn{2}{c}{TS1}\\
\showq\textquotestraightbase
\showq\textquotestraightdblbase
\showq\textquotesingle
\end{tabular}

\end{document}


It's advisable to use \textquotedbl rather than simply " to get straight double quotes even if your document encoding is T1. These will produce the same character (and " is easier to type) but using \textquotedbl will make your text more easily usable if it is reused in other contexts that may be set up to use other default encodings.

-
I can produce a straight apostrophe with \textquotesingle without either TS1 or T1, using the old OT1. –  Sverre Aug 28 '13 at 18:05
@Sverre by default you get  Undefined control sequence. \textquotesingle so you must have defined it somehow: there is no straight quote in OT1 just ' (which is only straight in tt fonts) –  David Carlisle Aug 28 '13 at 18:09
You're right. It's apparently defined by the libertine package. –  Sverre Aug 28 '13 at 18:23
@Sverre and produces ....\TS1/LinuxLibertineT-TLF/m/n/10 ' that is, it uses the TS1 encoded font for the symbol. –  David Carlisle Aug 28 '13 at 18:29

The OT1 font encoding does not contain a " character. However, T1 does.

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
"foo"
\end{document}

-
@TH, If he wants only some quotes to be straight, setting the global encoding will change all quotes in his document, right? –  xport Dec 25 '10 at 17:55
@xport: no, since most quotes are done with  and '' or  and ', and fontenc makes whatever arrangements are necessary for these to produce the usual results (which may well amount to \relax). –  SamB Dec 25 '10 at 18:00
@(TH, xport) With <code>\usepackage[T1]{fontenc}</code> I was only able to get straight double quotes; single quotes remained curly. And if I use <i>fontspec</i>, double quotes become curly too, —sorry I forgot to say I’m using XeLaTeX. –  JC Chu Dec 25 '10 at 19:42
@Jetcheng: Yeah, ' are still curly. xport's answer handled that (although I think you want the textcomp package–upquote does additional things). I'm afraid I don't know anything about XeLaTeX though. –  TH. Dec 25 '10 at 20:23
@xport: only by typing " will he get any "straight quotes"; I doubt if any variant of cmr actually has a straight ', though Knuth certainly has some designs for not only the conventional backtick (\') and single quote (' unless you have a strange font) glyphs, but also a forward tick glyph (which he offers as another possible rendition of ') -- see page 3 of the TeX book, or search for "American keyboards" in texbook.tex -- it's in the last sentence of the second paragraph of Chapter 2. –  SamB Dec 26 '10 at 5:36

% cf. http://ubuntuforums.org/showthread.php?t=1286215

Here are the {\ttfamily"}straight{\ttfamily"} quotes.

Here are the {\ttfamily\char'15}single{\ttfamily\char'15} quotes.


-
Switching the font is not really the nicest way. –  Martin Scharrer May 3 '12 at 13:31
@MartinScharrer Since this user is unregistered and likely not returning, I implemented your suggestion. I suggest you edit out the second half of your comment (and delete this comment of mine). –  doncherry Nov 29 '12 at 4:35

The units foot and inch should be abbreviated as ft and in, see e.g. Wikipedia.

For real quotes quoting someone, there is the excellent csquotes package. It has some very nice features for short quotes, blockquotes etc. And it will give gramatically correct quote marks.

If you just want single and double straight quote marks for some other use, you can use the package textcomp which makes available the commands \textquotesingle and \textquotedbl.

The following MWE contains examples for all three cases. As requested by the OP, it is compilable with XeLaTeX and makes use of \usepackage{fontspec}.

According to section 10.1 Ligatures of the fontspec documentation \defaultfontfeatures{Mapping=tex-text} in XeLaTeX is equivalent to \defaultfontfeatures{Ligatures=TeX}. As you noted, this will also alter your quotes. If you want ligatures AND straight quotes, use \defaultfontfeatures{Ligatures=Common} instead.

\documentclass{article}

\usepackage{textcomp}
\usepackage{siunitx}
\DeclareSIUnit\inch{in}
\DeclareSIUnit\feet{ft}

\usepackage{polyglossia}
\setmainlanguage[variant=american]{english}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=Common} % or Ligatures=TeX
\setmainfont{XITS}
\usepackage{unicode-math}
\setmathfont{XITS Math}

\usepackage[english=american]{csquotes}

%% ==================
\begin{document}
The \enquote{antique} table is \SI{5}{\feet} \SI{6}{\inch} long. \\
The \enquote{modern} table is \SI{168}{\centi\meter} long. \\
Just a \textquotesingle{}single\textquotesingle{} straight quote. \\
And \textquotedbl{}double\textquotedbl{} straight quotes.
\end{document}

-

I had the same question; how to get the apostrophe (U+0027) AKA the neutral, vertical, or straight single quote. I searched thoroughly and virtually all of the ‘solutions’ I found seemed to either have no effect in XeTeX, be overly complicated, and/or make additional undesired changes to the document, font, etc..

I have found one solution that works really well with XeTeX.

Define the apostrophe:

\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}


Use it!:

James\apostrophe{}, ‘wasn\apostrophe{}t’, it\apostrophe{}s, “\apostrophe{}tis”.


Using XeTeX, that should render like:

James', ‘wasn't’, it's, “'tis”.

For LyX users out there, I can confirm that this solution also works well in LyX (tested on version 2). Make sure that XeTeX is installed and ToolsReconfigure LyX if you have just installed XeTeX. In DocumentSettingsFonts, check ‘Use non-TeX fonts (via XeTeX/LuaTeX)’. I define the apostrophe in DocumentSettingsLaTeX Preamble. Then use Ctrl+L and enter \apostrophe{}

Btw, I've only recently started using XeTeX (I'm trying it out because I use so much Unicode!). Before the switch I was using the ‘\textquotesingle’ command from the ‘upquote’ package. This stopped working when switching to XeTeX. It wasn't very good though anyway because the apostrophe looked big and ugly; this XeTeX solution is much better and was definitely worth the time digging out!

-
Welcome to TeX.sx! –  texenthusiast Apr 7 '13 at 18:02
The only thing I'm missing now is to define ‘'’ as \apostrophe{} so that I don't have to type all that each time. If I want a right single quote (’), I just type it; I don't need LaTeX to stupidly try to be clever! Anyway, that's one for another day, I think I'll just settle with defining the apostrophe as ‘\¬’ for now. –  James Haigh Apr 7 '13 at 18:08

Uni-directional single and double quotes ' and " are not the correct characters for foot and inch marks.

You want to use a single and double prime respectively. Either use a font which has those characters (Hypatia Sans and Arno Pro are about the only two options when last I checked), or drop into math mode:

It’s said she was, “$$5' 2''$$ with eyes of blue.”

-