# LaTeX source code listing with less space between characters [duplicate]

I want to write shell Code in my LaTeX document. I'm using the listings package, with a code sample adapted from Tormod Fjeldskår:

\documentclass{report}

\usepackage{color}
\usepackage{xcolor}
\usepackage{listings}

\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}

% This concludes the preamble

\begin{document}

\begin{lstlisting}[label=some-code,caption=Some Code]
NETWORKING=YES

HOSTNAME= f e −19. l o c a l d o m a i n

}
\end{lstlisting}

\end{document}


The problem is that there is some extra space between every character when I generate a PDF. I would like the code without this space. The extra space is visible in the the part HOSTNAME=.

-

## migrated from stackoverflow.comFeb 22 '13 at 13:29

This question came from our site for professional and enthusiast programmers.

## marked as duplicate by Jubobs, Sean Allred, Andrew Swann, Charles Stewart, Svend TveskægApr 11 '14 at 18:24

– egreg Feb 22 '13 at 13:34
I would argue that this is not a duplicate, as the marked duplicate is asking about spaces between words, whereas this is referring to characters – texasflood Aug 27 '15 at 9:16

columns=fullflexible solved the problem.

By default, the spacing between characters is made uniform so as to preserve alignments. Setting columns to a non-default value restores the inter-character spacing (all characters are typeset at their natural width) but may break alignments.

For example:

\begin{lstlisting}[columns=fullflexible,caption=The Name]

Instead of fullflexible, you can use flexible or space-flexible, which try to preserve alignment by adjusting horizontal whitespace between words. For more information, see the section on the columns option in the listings manual (§2.10 “Fixed and flexible columns”).