I'm writing my dissertion using TeX. I would like to use a specific font in my lstlisting source code. How can I use a specific font like Monaco or Arial? I usually found solutions with basicstyle setted to \ttfamily but it's not what I want.

  • possible duplicate of Verbatim text can't be shown correctly in pdf – Marco Daniel Nov 10 '11 at 15:20
  • Welcome to TeX.SE. Altough it may seem trivial it is always best to compose a MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Nov 10 '11 at 15:23
  • @MarcoDaniel Why should this be a duplicate of that question? – egreg Nov 10 '11 at 16:19
  • @egreg: I am showing how you can set the font with the package listings and fancyvrb. – Marco Daniel Nov 10 '11 at 16:28
  • 4
    @egreg: I think the op is searching something like \lstset{basicstyle=\fontsize{10pt}{10}\usefont{OT1}{ptm}{m}{n}} – Marco Daniel Nov 10 '11 at 16:42

You can't use a font in TeX unless it's known to the TeX system. For example Monaco isn't, unless you use XeLaTeX or LuaLaTeX on Mac OS X. A good typewriter font for pdflatex can be BeraMono:


and then \ttfamily will use this font. You can say also scaled=.85 or some other number, in order to accommodate the size to your main font.

There's a clone of Courier


that sports a neat distinction between medium and bold weight (but might not agree with your main font).

However, you're not forced to use typewriter type for listings; if you say


you'll get whatever sans serif font is the default. You can change the default font by loading the suitable package; for example


will load a clone of Helvetica as the sans serif font and the above declaration will make this one the default. This package has a scale option similar to the scaled for beramono. Note that Arial is not considered to be a free font, so it's not in standard TeX distributions.

If you're using XeLaTeX or LuaLaTeX as typesetting engines, then you can use whatever OpenType or TrueType font you have on your system. For example, after having loaded fontspec you can define a suitable command


and then \lstset{basicstyle=\lstsansserif} would use Arial for listings.


Instead of \ttfamily you can use all the other commands which select a font. E.g.

\lstset{basicstyle=\fontfamily{pzc}\selectfont} %Zapf


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.