以下 Latex 产生的结果与我预期的一致:
\documentclass[a4paper,11pt]{article}
\usepackage{listings}
\usepackage{color}
\usepackage{tcolorbox}
\title{test}
\begin{document}
\maketitle
\lstdefinestyle{cs}{
basicstyle=\ttfamily\small,
breaklines=true,
framextopmargin=1pt,
framexbottommargin=1pt,
frame=tb,
framesep=3pt,
framerule=0pt,
showstringspaces=false,
tabsize=4,
numberstyle=\tiny\color{gray},
numbers=left,
stepnumber=1,
numbersep=8pt,
language=[Sharp]C,
keywordstyle=\color{blue},
commentstyle=\color{green!50!black},
stringstyle=\color{red},}
\begin{lstlisting}[prebreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},frame=single,caption={Test caption},captionpos=b]
1 2372065 1 R 52.21 52.21 0.00 1 2 0 0 0 0 0 8 9 0 0 0 0 14 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
\end{lstlisting}
\end{document}
但是,如果我在它上面添加第二个列表,似乎会破坏原始列表。例如,请参见下面的内容
\documentclass[a4paper,11pt]{article}
\usepackage{listings}
\usepackage{color}
\usepackage{tcolorbox}
\title{test}
\begin{document}
\maketitle
\lstdefinestyle{cs}{
basicstyle=\ttfamily\small,
breaklines=true,
framextopmargin=1pt,
framexbottommargin=1pt,
frame=tb,
framesep=3pt,
framerule=0pt,
showstringspaces=false,
tabsize=4,
numberstyle=\tiny\color{gray},
numbers=left,
stepnumber=1,
numbersep=8pt,
language=[Sharp]C,
keywordstyle=\color{blue},
commentstyle=\color{green!50!black},
stringstyle=\color{red},}
\begin{lstlisting}[style=cs]
public Contract(int cID, string tc)
\end{lstlisting}
\begin{lstlisting}[prebreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},frame=single,caption={Test caption},captionpos=b]
1 2372065 1 R 52.21 52.21 0.00 1 2 0 0 0 0 0 8 9 0 0 0 0 14 0 0 0 0 0 0 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
\end{lstlisting}
\end{document}
仅当我将样式添加到顶部列表时才会发生这种情况。为什么会发生这种情况?我该如何解决?谢谢。