当 breakindent 设置为 0pt 时,列表列表中会出现奇怪的额外空格

当 breakindent 设置为 0pt 时,列表列表中会出现奇怪的额外空格

在下面的示例中lstlisting,第三行开头有一个奇怪的多余空格。如您所见,它已被设置为breaklines=truebreakindent=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}

中断自动缩进=false

或者也许有额外的breakindent=1em

相关内容