3

Possible Duplicate:
listings bug: space after literate replacement lost with spaceflexible/fullflexible columns

I seem to have stumbled upon a minor bug in listings (version 1.4 as of 2007/02/22).

A space following a quotation mark (') is being collapsed in spaceflexible and fullflexible mode when using \lstinline, even though it appears properly rendered within lstlstings environment. Same problem occurs with double quotation mark ("), and problem persists with use of upquote. Problem appears to have something to do with detection of language strings, as it goes away if language={}.

Here is a minimal example demonstrating the problem. Note well that the space is lost immediately within the string literal, as well as the space just after the string literal but before the following + sign.

\documentclass{article}
\usepackage{listings}
\lstset{language=C, columns=fullflexible, showstringspaces=false}

\begin{document}

\noindent
\begin{tabular}{ll}
flexible & \lstinline[columns=flexible]!' A ' + ' B '!\\
spaceflexible & \lstinline[columns=spaceflexible]!' A ' + ' B '!\\
fullflexible & \lstinline!' A ' + ' B '!\\
\end{tabular}

\bigskip
\noindent
Within lstlisting environment with columns=flexible
\begin{lstlisting}[columns=flexible]
' A ' + ' B '
\end{lstlisting}

\noindent
Within lstlisting environment with columns=spaceflexible
\begin{lstlisting}[columns=spaceflexible]
' A ' + ' B '
\end{lstlisting}

\noindent
Within lstlisting environment with columns=fullflexible
\begin{lstlisting}
' A ' + ' B '
\end{lstlisting}

\end{document}

demonstration


I'd be interested to know if anyone else has experienced this, and if there is any patch that addresses the problem.

David Carlisle
  • 757,742
Michael
  • 301
  • Stumbled upon a different version of this problem, this time in both \lstinline and lstlisting, and involving literate replacement rather than string processing. In order to include code fragment, I've posted as new question – Michael Jan 23 '12 at 04:48

0 Answers0