在下面的示例中lstlisting
,第三行开头有一个奇怪的多余空格。如您所见,它已被设置为breaklines=true
和breakindent=0pt
。问题似乎是由于代码已缩进(这是故意的)。那么有什么方法可以解决这个问题吗?
\documentclass{article}
\usepackage{listings}
\lstset{
breaklines = true,
breakindent = 0pt,
basicstyle = \small\normalfont\ttfamily,
}
\begin{document}
\begin{lstlisting}
A:
When there is only one natural transformation between two functors, it implies that there is only one consistent way to map objects from the source category to objects in the target category while preserving the relationships between those objects. This uniqueness can have important implications in various mathematical contexts, providing insight into the properties and structure of the categories and functors involved.
\end{lstlisting}
\end{document}
答案1
通过您的例子,我没有得到您所显示的结果,但是:
这里可能会出现换行前一个空格。
我认为你想要的是:
\documentclass{article}
\usepackage{listings}
\lstset{
breaklines = true,
breakatwhitespace = true,
breakindent = 0pt,
basicstyle = \small\normalfont\ttfamily,
}
\begin{document}
\begin{lstlisting}
A:
When there is only one natural transformation between two functors, it implies that there is only one consistent way to map objects from the source category to objects in the target category while preserving the relationships between those objects. This uniqueness can have important implications in various mathematical contexts, providing insight into the properties and structure of the categories and functors involved.
\end{lstlisting}
\end{document}
或者:
\documentclass{article}
\usepackage{listings}
\lstset{
breaklines = true,
breakautoindent = false,
breakindent = 0pt,
basicstyle = \small\normalfont\ttfamily,
}
\begin{document}
\begin{lstlisting}
A:
When there is only one natural transformation between two functors, it implies that there is only one consistent way to map objects from the source category to objects in the target category while preserving the relationships between those objects. This uniqueness can have important implications in various mathematical contexts, providing insight into the properties and structure of the categories and functors involved.
\end{lstlisting}
\end{document}
或者也许有额外的breakindent=1em
。