Take the 2-minute tour ×
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.

When I am inside the lstlistings environment, it seems that using a quote such as (') or (") will toggle on the showing of whitespace indicators (small little half rectangles). Am I doing something wrong? Here is my listing definition:

\lstdefinestyle{verbo}{
    basicstyle=\scriptsize\ttfamily,
    breaklines=true,
    breakatwhitespace=true,
    tabsize=1,
    resetmargins=true,
    xleftmargin=0pt,
    frame=none,
} 

And here is the text that uses it:

\begin{lstlisting}[style=verbo]
- foo
 - bar' hello world
\end{lstlisting}

After the bar', all the spaces will printout with an ugly whitespace separator, e.g. between "hello" and "world". Is there a simple switch to disable this? I searched the listings documentation and could not find a way to do it.

Edit: Here a complete Example:

\documentclass[a4paper]{article}
\usepackage{color}
\usepackage[ngerman]{babel}

\usepackage{listings}
\lstset{
  language={XML},
  basicstyle=\ttfamily,
  showspaces=false
}

\begin{document}
\begin{lstlisting}[language=XML]
<test attr="Here should not be any whitespace-sign."/>
\end{lstlisting}
\end{document}

In the string these whitespace-signs occure, but they should not.

share
3  
that behaviour cannot be seen with current TeXLive. Create a complete example, which shows your behaviour. –  Herbert Aug 24 '11 at 5:55
    
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register here, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  doncherry Aug 24 '11 at 8:23
4  
This question appears to be off-topic because it's seems the problem reported by the OP can't be reproduced in up-to-date TeX distributions. –  Jubobs Mar 7 at 10:52
comments disabled on deleted / locked posts

migration rejected from stackoverflow.com Mar 7 at 11:46

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Jubobs, Martin Schröder, Jesse, Guido, Svend Tveskæg Mar 7 at 11:46

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

use showstringspaces=false, it is different to showspaces

share
add comment

When compiling the following minimal example under TeX Live 2011 (listings 2007/02/22, 1.4), there is no problem:

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\begin{document}
\lstdefinestyle{verbo}{
    basicstyle=\scriptsize\ttfamily,
    breaklines=true,
    breakatwhitespace=true,
    tabsize=1,
    resetmargins=true,
    xleftmargin=0pt,
    frame=none
}
\begin{lstlisting}[style=verbo]
- foo
- bar' hello world
\end{lstlisting}
\end{document}

Listings

However, considering the one of the first examples in the listings package documentation, this might be a default behaviour:

Listings with whitespaces visible

The option showspaces=false might be of help here, since showspaces=true in the above minimal example yields:

MWE listing with whitespaces visible

share
add comment