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:




% This concludes the preamble


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

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



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=.


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]
dladm show-phys

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”).

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