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

boldlistingstypewriter

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.

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.

\documentclass{article}
\usepackage{listings}
\begin{document}

% Default Computer Modern font (no bold implemented)
\renewcommand{\ttdefault}{cmtt}
\begin{lstlisting}[basicstyle=\ttfamily\bfseries]
y:=2
\end{lstlisting}

% Using Courier font
\renewcommand{\ttdefault}{pcr}
\begin{lstlisting}[basicstyle=\ttfamily\bfseries]
y:=2
\end{lstlisting}

\end{document}