[Tex/LaTex] How to make sure I get regular ASCII quotes in code examples when using `listings`

listingspunctuation

So I am writing a book on AWK and when using listings code highlighting module, I get the fancy quotes “ ” and ‘ ’ instead of the regular ASCII ones " " and ' '. I hate these fancy quotes because when copying code examples from a PDF, they never work in the terminal.

Does anyone know how to make all code examples use only ASCII quotes?

I found out that you can set \lstset{upquote=true} and that fixes the single quotes ' ' but the double ones are still broken.

Any ideas?

Best Answer

Use a sensible fontencoding. And make a complete example next time so that nobody has to guess what you are doing wrong.

\documentclass{article}
\usepackage{listings}
\usepackage[T1]{fontenc}
\begin{document}

\begin{lstlisting}
"a"
\end{lstlisting}
\end{document}

Btw: Don't rely to much on copying code from a pdf. Spaces can disappear.

Related Question