# Consolas: Straight Quotes

I am using the listings-Package to display code. As I am using The Consolas Font as the Monotype-Default I expected straight quotes which isn't the case (check my MWE)

 \documentclass[a4paper]{article}
\usepackage{listings}
\usepackage{polyglossia}
\setdefaultlanguage[]{english}

\setmonofont[Ligatures=TeX]{Consolas}

\lstset{frame=single}

\begin{document}
\begin{lstlisting}
"some code to try"
\end{lstlisting}

\end{document}


Can Anyone help How to get straight quotes?

• listings doesn't use the monospaced font by default, add basicstyle=\ttfamily to \lstset. – Torbjørn T. Nov 11 '13 at 14:12
• That does not work @TorbjørnT. Is it because I use XeLaTex? – Kathiieee Nov 11 '13 at 14:15
• After testing I see that it still does not produce straight quotes, but it should at least be using Consolas after adding that. Given that Consolas should give straight quotes, I don't know why the quotes appear as they do, I'm afraid. – Torbjørn T. Nov 11 '13 at 14:19

This is actually caused by Ligatures=TeX, which causes fontspec to automatically convert a " to curly quotes, it appears. Further, as I mentioned in a comment, listings does not use the monotype font by default, so to actually use Consolas in the listings, add basicstyle=\ttfamily to lstset.

\documentclass[a4paper]{article}
\usepackage{listings}
\usepackage{polyglossia}
\setdefaultlanguage[]{english}

\setmonofont{Consolas}

\lstset{frame=single,basicstyle=\ttfamily}

\begin{document}
\begin{lstlisting}
"some code to try"
\end{lstlisting}
\end{document}


• This works perfectly thanks! @Torbjørn T. Another question: What is the difference between \defaultfontfeatures{Mapping=tex-text} and the Ligatures=TeX? – Kathiieee Nov 11 '13 at 14:49
• @Kathiieee Nothing, see the fontspec manual. I quote: 'Mapping enables a XeTeX text-mapping scheme, shown in Example 43. Using the tex-text mapping is also equivalent to writing Ligatures=TeX.' – Torbjørn T. Nov 11 '13 at 14:52