Below are two examples of fonts. The first is from the verbatim environment (which I read has default font ttfamily). The second is from a lstlisting with basicstyle=\ttfamily. They look different. It looks like the second has more space between the letters. What is happening? And how to I get the lstlisting example to look like the verbatim example?

two code fonts

  • 1
    Look for basewidth in the listings documentation to adjust the width for every character. If you want a more detailed answer, you should add a MWE. May 30, 2021 at 17:31
  • 1
    Please consider to upvote and/or accept the provided answer so that the process comes to an end :). May 31, 2021 at 2:02

1 Answer 1


Like hinted by @MarcelKrüger the difference has to do with the basewidth key of listings.

listings prints its output to a fixed width (that can be specified with \lstset{basewidth=<width>}, or in the optional argument of lstlisting), this way also proportional fonts can be used for code listings.

You can turn this column format off by using columns=fullflexible:



some code about stuff
other code about stuff

some code about stuff
other code about stuff

enter image description here

  • Amazing, thank you!
    – dfrankow
    May 30, 2021 at 18:45
  • 1
    @dfrankow usually we don't say thank you via comments but via votes. But I'm glad I could help.
    – Skillmon
    May 30, 2021 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .