4

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?

8

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.

  • Perfect! \usepackage[T1]{fontenc} did it. – Peter Krumins Apr 30 '11 at 11:01
  • Did not help in my case, even when placing it immediately above the lstset code. Also, what do you do if you need a really sensible font encoding, which supports unicode? – Zelphir Jul 17 '17 at 12:27
  • @Zelphir: Don't use comments to ask new questions. – Ulrike Fischer Jul 17 '17 at 12:31
  • @UlrikeFischer I thought maybe this answer could be improved by not limiting it to \usepackage[T1]{fontenc}, that's why I commented. If I start a new question for such details, it'll get marked as duplicate - people are very quick to do that. Also I don't have an "MWE", so all I'll get is "MWE please!". However, my own setup is quite complex with loads of packages. Any solution for a MWE might not translate into a solution for my specific case. The MWE would have to be my whole template, so that I can be sure. – Zelphir Jul 17 '17 at 12:36
  • So you are too lazy to make a good question and prefer that I spent my time to extend the question to lualatex? – Ulrike Fischer Jul 17 '17 at 12:41

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.