18

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?

26

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}
  • is it possible to show the quotation as example1 or example2 – alhelal Sep 26 '17 at 10:33
  • @jubobs could you please elaborate on this example a bit? The listings.sty file actually only handles single quotes, but your example does compiles to straight double quotes. However, I ran into a failed example as well. – wlnirvana Oct 25 '18 at 1:25
  • @wlnirvana Your problem probably deserves a brand new question on this site. – jub0bs Oct 25 '18 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.