\lstnewenvironment 有损坏的分页符

\lstnewenvironment 有损坏的分页符

我已经设置了以下环境:

\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 页:

2 页面示例

3 页或更多页:

3 页面示例

我摆弄过环境设置,但没有找到在页面之间设置合理间隔的方法,我想知道如何解决这个问题。

相关内容