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?


1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .