# How does one display straight quotes in the normal font?

From this code:

\subsubsection{General Escaping Format}
Generally, escaping MUST be done in a manner similar to most programming
languages, such as C, C++, Java, or similar, for quoted string escapes. Such an
escaping scheme is defined by three characters: a starting delimiter, a
termination delimiter, and an escape character. For instance, in C, the starting
delimiter is the quote mark, ", the ending delimiter is also a quote
mark ", and the escape character is the backslash \textbackslash.


XeTeX gives this:

Note in particular the quotes that I want to be raw C style " characters, are converted into a pair of right curly quotes. Of course, I'm talking about programming languages in this section, so I need the quotes to be displayed as typewriter style straight quotes. I can force the straight quotes if I use \verb, but this causes the quotes to look strange because the actual font is different.

• @AlanMunn: Ah, that does seem to be the problem. If I change the main font to something like Times New Roman it "just works". Why not make that an answer? – Billy ONeal Feb 6 '12 at 5:45
• In theory you could change the verbatim font by redefining an internal macro. Also \Verbdef\dblq{"} and then \dblq (newverbs package) should do it, but Werners answer is much better anyway. – Martin Scharrer Feb 6 '12 at 10:48
• This is code, you should use \texttt or \verb or \lstinline or … If you find the output weird, change your typewriter font. – Andrey Vihrov Feb 6 '12 at 18:54
• @AndreyVihrov: Ah, that is a good point. Perhaps I should find a typewriter font that does not clash so violently with my main text. Now to find out how to define a user defined font... – Billy ONeal Feb 6 '12 at 19:00

You can use \textquotedbl with

\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc


Here is a display of the output:

\documentclass{article}
\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\begin{document}
\setcounter{section}{3}\setcounter{subsection}{1}% Just for this example
\subsubsection{General Escaping Format}
Generally, escaping MUST be done in a manner similar to most programming
languages, such as C, C++, Java, or similar, for quoted string escapes. Such an
escaping scheme is defined by three characters: a starting delimiter, a
termination delimiter, and an escape character. For instance, in C, the starting
delimiter is the quote mark, \textquotedbl, the ending delimiter is also a quote
mark \textquotedbl, and the escape character is the backslash \textbackslash.
\end{document}

• Just my 2 cents concerning graphical design: the typewriter font is there to typeset pieces of code as well, isn't it? ... and since " and <backslash> are pieces of code in this case... – yo' Feb 6 '12 at 9:05
• The question mentions XeTeX so T1-encoding is not a suitable encoding. With the EU1-encoding set by fontspec \textquotedbl will not work as the ligatures setting mentioned by Enrico will interfere. – Ulrike Fischer Feb 6 '12 at 11:37

The problem is in the Ligatures=TeX option that is automatically added when you say only

\usepackage{fontspec}


so using the Latin Modern fonts. If you redefine the font without the option, then typing " will give straight quotes. So

\usepackage{fontspec}
\setmainfont{Latin Modern Roman}


If however you want to keep the other "traditional ligatures", you can make a copy of text-tex.map, call it text-tex-sq.map (for instance), and modify it to read as

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "TeX-text"
RHSName "UNICODE"

pass(Unicode)

; ligatures from Knuth's original CMR fonts
U+002D U+002D                   <>      U+2013  ; -- -> en dash
U+002D U+002D U+002D    <>      U+2014  ; --- -> em dash

U+0027                  <>      U+2019  ; ' -> right single quote
U+0027 U+0027   <>      U+201D  ; '' -> right double quote
;U+0022                   >      U+201D  ; " -> right double quote ; no change!

U+0060                  <>      U+2018  ;  -> left single quote
U+0060 U+0060   <>      U+201C  ;  -> left double quote

U+0021 U+0060   <>      U+00A1  ; ! -> inverted exclam
U+003F U+0060   <>      U+00BF  ; ? -> inverted question

; additions supported in T1 encoding
U+002C U+002C   <>      U+201E  ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C   <>      U+00AB  ; << -> LEFT POINTING GUILLEMET
U+003E U+003E   <>      U+00BB  ; >> -> RIGHT POINTING GUILLEMET


Compile with teckit_compile tex-text-sq.map and keep the text-text-sq.tec file that will be produced in the same directory as your file: now the call

\usepackage{fontspec}
\setmainfont[Mapping=tex-text-sq]{Latin Modern Roman}


will give the "traditional ligatures" but keep straight double quotes straight.

• I personally would remove all ligatures with the exception of -- and ---. Actually I think it would be a good idea if there would exist a fontspec option "Ligatures=onlydashes". – Ulrike Fischer Feb 6 '12 at 11:40
• @UlrikeFischer Legacy documents use the traditional ligatures. I would drop U+0022 > U+201D altogether from tex-text.map: the fact that "` produced a closing double quote is only an artifact of history (and only in OT1 encoding). – egreg Feb 6 '12 at 11:49