TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I load the listing package to set nice code and change the font size (like suggested there: Shrinking monospace style for listings package), I lose the syntax highlighting, because the font does not get bold anymore.


  int a = 5;
  //int should be bold, it's not.
  //commenting out basicstyle makes it bold, but to big

Is there some way to change the font size of listings without losing code highlighting?

share|improve this question
up vote 10 down vote accepted

I just found the answer myself by trial-and-error:


So you don't have to overwrite the font family, contrary to what the answer in the linked question suggested.

share|improve this answer
The standard monospaced font (Computer Modern Typewriter) has no bold variant. If you load \usepackage{lmodern}, then you'll get boldface also with \ttfamily. – egreg Mar 29 '13 at 22:13

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.