Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've been using the listings package for a while, but have only recently noticed that the underscore is rendered with less width than the other characters. I'm working on some code snippets now which use a lot of variables containing an underscore, and so I see the effect more than ever. Is there any way to prevent this?

share|improve this question
Related Question: Getting incorrect underscores from macro in an lstlisting. – Peter Grill Nov 17 '12 at 5:35

1 Answer 1

up vote 8 down vote accepted



in your preamble. The default underscore in OT1 encoding is indeed quite small.

If you don't want to switch font encoding, then the following code in the preamble will produce a similar underscore:

  \leavevmode\kern0.03em\vbox{\hrule\@width.6em \@height-.25ex \@depth0.37ex}\kern0.03em}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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