Verbatim 环境使用选项 [samepage=true] 插入空白页

Verbatim 环境使用选项 [samepage=true] 插入空白页

我正在使用该fancyvrb包将 RFC 添加到我的附录中。RFC 已使用定义的站点布局进行了预格式化。我正在使用Verbatim带有samepage=true选项的环境,以避免拆分固定页面并将其拆分为多个页面。

但是,此选项会插入一个空白页附录章节。下面是一个简单的在职的例如,请忽略格式错误的格式:

\documentclass{book}
\usepackage{fancyvrb}
\begin{document}
\chapter{Lorem polorem}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.\par
\chapter{Ipsum popipsum}
\begin{Verbatim}[samepage=true]
Lorem Ipsum Translation                                       H. Rackham
Internet-Draft                                     Lorem Ipsum Institute
Intended status: Official                               October 18, 1914
Expires: December 31, 9999


                         Lorem Ipsum Translation
                     draft-ietf-lorem-ipsum-spec-1914

Translation

   But I must explain to you how all this mistaken idea of denouncing
   pleasure and praising pain was born and I will give you a complete
   account of the system, and expound the actual teachings of the great
   explorer of the truth, the master-builder of human happiness.  No one
   rejects, dislikes, or avoids pleasure itself, because it is pleasure,
   but because those who do not know how to pursue pleasure rationally
   encounter consequences that are extremely painful.  Nor again is there

   anyone who loves or pursues or desires to obtain pain of itself,
   because it is pain, but because occasionally circumstances occur in
   which toil and pain can procure him some great pleasure.  To take a
   trivial example, which of us ever undertakes laborious physical
   exercise, except to obtain some advantage from it? But who has any
   right to find fault with a man who chooses to enjoy a pleasure that has

   right to find fault with a man who chooses to enjoy a pleasure that has
   no annoying consequences, or one who avoids a pain that produces no
   resultant pleasure?

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 1878 and BCP 1879.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on December 31, 9999.





Rackham                  Expires December 31, 9999              [Page 1]
\end{Verbatim}
\end{document}

告诉 verbatim 使用scriptsize字体会使该页面适合一页。但我无法删除插入的空白页附录。

将 Verbatim 环境设置为samepage=false删除空白页但拆分 RFC 页面并将最后几行移动到新页面,而这并不是我想要的。

知道如何解决该问题吗?

答案1

日志文件显示您的尺寸太大了 250pt,因此您只需做出一些选择即可使其适合。

我在这里做了一些任意的设置,只是在每个阶段检查页面的过度程度。

  • 将逐字字体大小减小到 \small

  • \@makechapteread复制了from的定义book.cls并无端攻击它以占用更少的空间。

  • 添加\enlargethispage以消除有关箱子过满的最后警告。

所有这些内容都只是出现在页码上方

在此处输入图片描述

\documentclass{book}
\usepackage{fancyvrb}
\begin{document}
\chapter{Lorem polorem}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.\par

\makeatletter
\def\@makechapterhead#1{%
%  \vspace*{50\p@}%
   \vspace*{-60pt}
  {\parindent \z@ \raggedright \normalfont
    \huge\bfseries \@chapapp\space \thechapter
    \quad #1\par\nobreak
%    \vskip 40\p@
    \vskip 10\p@
  }}

\chapter{Ipsum popipsum}
\enlargethispage{80pt}
\begin{Verbatim}[samepage=true,fontsize=\small]
Lorem Ipsum Translation                                       H. Rackham
Internet-Draft                                     Lorem Ipsum Institute
Intended status: Official                               October 18, 1914
Expires: December 31, 9999


                         Lorem Ipsum Translation
                     draft-ietf-lorem-ipsum-spec-1914

Translation

   But I must explain to you how all this mistaken idea of denouncing
   pleasure and praising pain was born and I will give you a complete
   account of the system, and expound the actual teachings of the great
   explorer of the truth, the master-builder of human happiness.  No one
   rejects, dislikes, or avoids pleasure itself, because it is pleasure,
   but because those who do not know how to pursue pleasure rationally
   encounter consequences that are extremely painful.  Nor again is there

   anyone who loves or pursues or desires to obtain pain of itself,
   because it is pain, but because occasionally circumstances occur in
   which toil and pain can procure him some great pleasure.  To take a
   trivial example, which of us ever undertakes laborious physical
   exercise, except to obtain some advantage from it? But who has any
   right to find fault with a man who chooses to enjoy a pleasure that has

   right to find fault with a man who chooses to enjoy a pleasure that has
   no annoying consequences, or one who avoids a pain that produces no
   resultant pleasure?

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 1878 and BCP 1879.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on December 31, 9999.





Rackham                  Expires December 31, 9999              [Page 1]
\end{Verbatim}
\end{document}

但我突然想到,您可能会问为什么它在第 3 页而不是第 2 页,章节开头默认在右侧(奇数)页,如果不需要,请添加[openany]选项。\documentclass

相关内容