# Set font size in pt in a listing

How can I set the `basicstyle` option to force the use of 9pt fonts in listings regardless of the default size of the document?

Using 9pt fonts is a requirement of the guidelines that I am using, so I must be sure that it stays that way even if I change other font settings.

-

Usually one sets the size of listings in a dynamic way with commands such as `\small`. However, nothing prevents you from using lower level commands:

``````basicstyle=\fontsize{9}{11}\ttfamily
``````

or

``````basicstyle=\fontsize{9}{11}\selectfont
``````

The second is if you want to use the normal font also in listings. The `\selectfont` instruction is implicit in commands such as `\ttfamily`.

The second argument to `\fontsize` is the baseline skip to use.

-