我正在使用 listings 包来包含源代码。这种方法效果很好,但是,有时行会断开,但输入不会在下一行继续,只会显示断开后的箭头。
似乎 listings 包计算换行符不正确,或者将 postbreak 指定的任何内容考虑在内。我已经检查过了清单手册但还没有找到解决这个问题的方法。
最小工作示例是:
\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}
输出为: