Does anyone know how to change the font for code snippets in the listings package? I'd like to have a constant width font, rather the fancy variable-width looking font that it has by default.
Asked
Active
Viewed 1.1k times
14
lockstep
- 250,273
1 Answers
15
As shown at page 28 of the manual, adding the option
basicstyle=\ttfamily
to the \lstset{} command would make what you ask.
Keep in mind to always read the packages documentation on your machine before posting.
Spike
- 6,729
-
4I find
basicstyle=\footnotesize\ttfamilyeven better for the default LaTeX layout. – Andrey Vihrov Apr 30 '11 at 11:14 -
http://tex.stackexchange.com/questions/33685/set-the-font-family-for-lstlisting – Say OL Aug 26 '13 at 10:22
-
3Keep an open mind: Peteris Krumins maybe tried to read the documentation and found it incomprehensible. Actually, that's why I'm here. +1 for your answer. – User 17670 Oct 28 '13 at 17:41
fontas you did. I have the listings package PDF, I did a 15-minute search of the 58-page document, and the answer was not obvious to me. I needed the answer faster than having to read 58 pages first (just to change a font). Google led me to StackExchange and this page and the answer right away. Thank you for saving me time. – gknauth Apr 17 '13 at 21:11