[Tex/LaTex] Using \ttfamily with \bfseries (or how to enable bold in fixed-width font)


I'm using listings package, and I've added basicstyle=\ttfamily\footnotesize. However, when I do that, the keywords from the embedded source-code are not bold anymore.

I figured that \ttfamily together with \bfseries does not work.

And then I found a FAQ about bold-extras, and I tried adding \usepackage[bold-extras], and it didn't work either. What does that package do? Should I just ignore it and move on?

And then I finally found Using bold/italic text inside listings?, which may be a duplicate to this one, but was a lot harder to find. I also found Bold Typewriter Type fonts, which got me more confused.

So, what should I do in order to get a bold fixed-width font for use within listings?

Using pdflatex from texlive-2010.

Best Answer

As Martin mentioned in the comment you need a font which provides such a combination. In the following example you can see that the font courier has this combination implemented instead of Computer Modern.


% Default Computer Modern font (no bold implemented)

% Using Courier font


The first "y:=2" is not rendered as bold, but the second one is.