# Possible to adjust character width?

I'm using Beamer and lstlisting to put some code in a presentation.

The character spacing feels a bit too wide to my eye. Is it possible to reduce it? I've tried searching on this SE but can't seem to see anything obvious.

EDIT:

This seems trivial but:

\begin{frame}[fragile]
\frametitle{A frame}
\begin{lstlisting}
the letters are too far apart
\end{lstlisting}
\end{frame}

-
Welcome to TeX.SX! Could you please add an example of what you mean? –  egreg Sep 10 '12 at 14:48
Done, unless you want the complete file, \usepackage and all? –  Joe Sep 10 '12 at 14:57
Try \begin{lstlisting}[columns=fullflexible] and tell whether it's better. –  egreg Sep 10 '12 at 15:02
@Joe: better would be a complete example, because you can use some options loading package listings which could be important ... –  Kurt Sep 10 '12 at 15:04
Thanks @egreg that is exactly what I wanted. Give it as an answer and I'll tick it. –  Joe Sep 10 '12 at 15:10

The default setting of listings is to place each character in a box in order to ensure vertical alignment emulating terminal output.

However, this may not be nice when the default font is proportionally spaced. There are two solutions (actually one):

\lstset{columns=fullflexible}


in the document preamble will typeset in normal character boxes. However, usually listings are typeset with a monospaced font, so

\lstset{columns=fullflexible,basicfamily=\ttfamily}


will do both settings.

The key-value pair can also be specified on a local basis:

\begin{lstlisting}[columns=fullflexible,basicfamily=\ttfamily]


will apply the settings only to that lstlisting environment.

The key keepspaces will also avoid merging two spaces into one.

-
Brilliant thanks. –  Joe Sep 10 '12 at 15:18