Take the 2-minute tour ×
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.

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.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

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.