![为什么在另一个列表上方添加列表会弄乱原始列表的格式](https://linux22.com/image/463657/%E4%B8%BA%E4%BB%80%E4%B9%88%E5%9C%A8%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%88%97%E8%A1%A8%E4%B8%8A%E6%96%B9%E6%B7%BB%E5%8A%A0%E5%88%97%E8%A1%A8%E4%BC%9A%E5%BC%84%E4%B9%B1%E5%8E%9F%E5%A7%8B%E5%88%97%E8%A1%A8%E7%9A%84%E6%A0%BC%E5%BC%8F.png)
以下 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}
仅当我将样式添加到顶部列表时才会发生这种情况。为什么会发生这种情况?我该如何解决?谢谢。