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.

I have the following set up for my listings :

\lstset{basicstyle=\footnotesize,breaklines=true}
\lstset{framextopmargin=50pt,frame=bottomline}

I would like to change the font family to Courier. How can I enable this?

share|improve this question
    
Why not just use a monospaced font like \ttfamily (from Computer Modern)? –  Werner Nov 4 '11 at 20:44
    
@Werner I am sorry but I am not following you here. You might have got that I am newbie :s –  tugberk Nov 4 '11 at 20:45
1  
It is recommendable to take a look at Section 4.6 of the listings manual. –  Thorsten Donig Nov 4 '11 at 20:51
3  
@tugberk: See @Peter's answer. basicstyle=\ttfamily prints the listing content using \ttfamily - a monospaced font. –  Werner Nov 4 '11 at 20:52
    
@Werner thanks a lot. I got it right now. –  tugberk Nov 4 '11 at 20:53

2 Answers 2

up vote 13 down vote accepted

With \usepackage{courier} in your preamble you can use the courier font in the listings as follows:

\documentclass[12pt]{article}
\usepackage{listings}
\usepackage{lipsum}
\usepackage{courier}

\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\lstset{framextopmargin=50pt,frame=bottomline}

\begin{document}
\begin{lstlisting}
   a b c
\end{lstlisting}
\lipsum[1]
\end{document}

The \usepackage{courier} in the preamble causes \ttfamily to produce output in the courier font. Without including this package, you can still use \ttfamily to get a mono spaced font by including that as part of the basicstyle=... setting.

share|improve this answer

Modify your basicstyle to include the font family:

\lstset{basicstyle=\ttfamily\footnotesize,breaklines=true}
share|improve this answer

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.