I am using the listings package to include source code. This works pretty well, however, sometimes lines are broken, but the input does not continue on the following line, only the postbreak arrow is displayed.
It seems that the listings package calculates line breaks incorrectly or takes whatever is specified by postbreak into account. I already checked the listings manual but have not found a solution to this problem.
Minimal working example is:
\documentclass[12pt, a4paper]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{newcent}
\usepackage{color} % requirement
\usepackage{listings} % reference source code
% a version without custom colors taken from classicthesis
\lstset{language=Haskell,%[LaTeX]Tex,%C++,
morekeywords={PassOptionsToPackage,selectlanguage},
keywordstyle=\color{blue},%\bfseries,
basicstyle=\small\ttfamily,
%identifierstyle=\color{NavyBlue},
commentstyle=\color{green}\ttfamily,
stringstyle=\ttfamily,
numbers=left,%none
numberstyle=\scriptsize,%\tiny
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
breakatwhitespace=false,
%frameround=ftff,
frame=tb,
belowcaptionskip=.75\baselineskip,
captionpos=b,
literate={\>}{}{0\discretionary{>}{}{>}},
%frame=L
}
\begin{document}
\chapter{Hello World}
\section{Minimal Working Example}
aaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb \lstinline{all} do not use lambda functions.
\end{document}
Output is:
\lstset
to concentrate on problem. Anyway, the problem does not appear to show in this mwe if usingbreakatwhitespace=true
, and the fact that it does withbreakatwhitespace=false
is probably a bug. You should report to package maintainer.breakatwhitespace=true
alone is not an option, because then I get overlong lines.