使用 fancyvrb 防止页面开头出现空行

使用 fancyvrb 防止页面开头出现空行

我在使用 的文档中有一些相当长的代码清单fancyvbr。这些清单包含空行,以便直观地将代码分成几部分。如果清单跨页,这些空行将位于新页面的顶部,这看起来不太美观。有没有办法自动删除这些空行?

示例代码

\documentclass{article}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}

\begin{document}

\pagestyle{empty}

\begin{Highlighting}
  ASDF ASDF ASDF1
  ASDF ASDF ASDF2
  ASDF ASDF ASDF3
  ASDF ASDF ASDF4
  ASDF ASDF ASDF5

  ASDF ASDF ASDF6
  ASDF ASDF ASDF7
  ASDF ASDF ASDF8
  ASDF ASDF ASDF9
  ASDF ASDF ASDF10

  ASDF ASDF ASDF11
  ASDF ASDF ASDF12
  ASDF ASDF ASDF13
  ASDF ASDF ASDF14
  ASDF ASDF ASDF15

  ASDF ASDF ASDF16
  ASDF ASDF ASDF17
  ASDF ASDF ASDF18
  ASDF ASDF ASDF19
  ASDF ASDF ASDF20

  ASDF ASDF ASDF21
  ASDF ASDF ASDF22
  ASDF ASDF ASDF23
  ASDF ASDF ASDF24
  ASDF ASDF ASDF25

  ASDF ASDF ASDF26
  ASDF ASDF ASDF27
  ASDF ASDF ASDF28
  ASDF ASDF ASDF29
  ASDF ASDF ASDF30

  ASDF ASDF ASDF31
  ASDF ASDF ASDF32
  ASDF ASDF ASDF33
  ASDF ASDF ASDF34
  ASDF ASDF ASDF35

  ASDF ASDF ASDF36
  ASDF ASDF ASDF37
  ASDF ASDF ASDF38
  ASDF ASDF ASDF39



  ASDF ASDF ASDF40

  ASDF ASDF ASDF41
  ASDF ASDF ASDF42
  ASDF ASDF ASDF43
  ASDF ASDF ASDF44
  ASDF ASDF ASDF45

  ASDF ASDF ASDF46
  ASDF ASDF ASDF47
  ASDF ASDF ASDF48
  ASDF ASDF ASDF49
  ASDF ASDF ASDF50

  ASDF ASDF ASDF51
  ASDF ASDF ASDF52
  ASDF ASDF ASDF53
  ASDF ASDF ASDF54
  ASDF ASDF ASDF55

  ASDF ASDF ASDF56
  ASDF ASDF ASDF57
  ASDF ASDF ASDF58
  ASDF ASDF ASDF59
  ASDF ASDF ASDF60
\end{Highlighting}

\end{document}

示例输出

在此处输入图片描述

相关内容