[Tex/LaTex] How to get straight double quotes in listings

listingssymbolstextcomp

My question is related to the following two

but I'm specifically asking about double-quote characters (ASCII decimal code 34).
They appear curly in my listings. How can I get straight double quotes instead?

MWE:

\documentclass{article}
\usepackage{textcomp,upquote,listings}
\lstset{upquote=true}
\begin{document}
\begin{lstlisting}
echo "Hello, world!"
\end{lstlisting}
\end{document}

produces

Output of the provided MWE; contains closing curly quotes

I understand that the upquote package only applies to single quotes. How can I make it apply to double quotes as well?

Best Answer

Simply add \usepackage[T1]{fontenc} to your preamble. Note that you don't need the upquote package if you load textcomp and set listings' upquote key to true.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{listings}
\lstset{upquote=true}
\begin{document}
\begin{lstlisting}
echo "Hello, world!"
\end{lstlisting}
\end{document}