TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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

share|improve this question

migrated from stackoverflow.com Feb 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æg Apr 11 '14 at 18:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Related: tex.stackexchange.com/questions/21432/… – 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]
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”).

share|improve this answer

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