1

Is it possible to use consolas as the default teletype font to display code listings using the listings package? The default computer modern teletype font is too wide for my taste.

Edit: I am using regular LaTeX.

1
  • 4
    In case XeLaTeX is a valid answer: XeLaTeX.
    – Manuel
    May 25, 2014 at 21:48

2 Answers 2

10

You can use Consolas using either XeLaTeX or LuaLaTeX with the fontspec package.

If you want Consolas to be your default monospaced font for everything:

Add the following code to your preamble:

\usepackage{fontspec}
\setmonofont{Consolas}

There are other options you can pass to \setmonofont; see the fontspec documentation.

If you only want Consolas for your code listings:

Add the following code to your preamble:

\usepackage{fontspec}
\newfontfamily\Consolas{Consolas}
\lstset{basicstyle=\Consolas}

Again there are additional options you can pass to \newfontfamily.

0

The approach that works for me is to use the Inconsolata font as detailed in the following answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .