我設定了以下環境:
\lstdefinelanguage{prompt}{}
\lstnewenvironment{prompt}{%
\lstset{language=prompt,
frame=none,
aboveskip=1.5mm,
belowskip=1.5mm,
showstringspaces=false,
columns=fullflexible,
basicstyle={\scriptsize\ttfamily},
numbers=none,
%numbers=left,
%firstnumber=0,
numberstyle=\scriptsize\color{gray},
keywordstyle=\color{black},
commentstyle=\color{black},
stringstyle=\color{black},
breaklines=true,
breakatwhitespace=true,
postbreak={\mbox{$\hookrightarrow\space$}},
tabsize=2,
xleftmargin=1em,
xrightmargin=0pt,
breakindent=0pt,
resetmargins=true,
breakautoindent=false
}
\mdframed[%
innertopmargin=5pt,
middlelinewidth=1pt,
outerlinewidth=9pt,outerlinecolor=white,
innerleftmargin=3pt,
innerrightmargin=3pt,
leftmargin=-9pt,rightmargin=-10pt,
skipabove=\topskip,
skipbelow=\topskip,
roundcorner=3pt,
singleextra={\node[draw, fill=white,anchor=west, xshift=10pt+1pt,font=\bfseries] at (O|-P) {Prompt};},
firstextra={\node[draw, fill=white,anchor=west, xshift=10pt+1pt,font=\bfseries] at (O|-P) {Prompt};}
]%
}{\endmdframed}
如果實例內的文字區塊足夠小以適合頁面,則此方法可以正常運作並列印良好:
然而,當它必須被分成 2 份時,標題會以一種看起來很尷尬的方式留在後面,如果它被分成 3 份,那麼每頁只打印一行,直到最後一行:
2 頁:
3頁或更多頁:
我擺弄了環境設置,但還沒有找到一種在頁面之間進行合理中斷的方法,我想知道如何解決這個問題。