TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

I have a LaTeX document, and am trying to embed some Java code via the listings package. I have the following LaTeX source:

\title{Sample Document}

\section*{Source Code:}

\lstset{ language=Java }


And, for the most part, the code shows up nicely. But, in certain places I get these weird symbols where spaces should be (code coloring added):

In certain places there are weird |_| symbols instead of spaces

It appears that, within any quoted string, the spaces are converted to these U-like symbols. Any idea why this is happening?

share|improve this question
Can you please add a minimal working example illustrating the problem? – Gonzalo Medina Nov 2 '11 at 0:45
Those are there to indicate that there is a space. – Peter Grill Nov 2 '11 at 0:47
up vote 7 down vote accepted

Spaces in strings appear as the symbol you mentioned. To suppress the symbols showing the spaces, add the option showstringspaces=false to \lstset.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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