如何制作“故意留空”的页面?

如何制作“故意留空”的页面?

我有一个scrbook文档openright,其中有一个选项,即文档中偶尔会出现空白的左页。并不是我真的想这样做,但我如何才能干净利落地将臭名昭著的“此页面故意留空”包含在这些空白页中,即没有太多的黑客攻击?

如果在每一页空白页上都加上不同的名言,而不是使用枯燥的默认语调,则可以获得加分;)

答案1

您可以重新定义\cleardoublepage。以下是示例:

\documentclass[openright]{scrbook}
\newcommand*{\blankpage}{%
\vspace*{\fill}
{\centering This page would be intentionally left blank if we would not wish to inform about that.\par}
\vspace{\fill}}
\makeatletter
\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\blankpage
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\begin{document}
Text
\chapter{First chapter}
\end{document}

\blankpage只打印您喜欢的内容,垂直和水平居中。

答案2

memoirhas \cleartooddpage(和\cleartoevenpage) 就是做这个的。从手册中解释:

可选参数的一个可能示例是

\cleartooddpage[\vspace*{\fill}   
THIS
PAGE ACCIDENTALLY PRINTED
ON   
\vspace*{\fill}]

这会将“此页意外打印于”放在任何可能被跳过的(空的)偶数页的中心。

答案3

我还没有看到一个答案可以处理水平和垂直方向上的正确居中。为了进行分析,我们采用了 Stefan Kottwitz 的答案:

% Set parameters for analyzing/debugging
\showboxdepth=\maxdimen
\showboxbreadth=\maxdimen
\tracingonline=1

\documentclass[openright]{scrbook}
\newcommand*{\blankpage}{%
  \vspace*{\fill}
  \centering
  This page would be intentionally left blank if we would not wish
  to inform about that.
  \vspace{\fill}%

  \showlists
}
\makeatletter
\renewcommand*{\cleardoublepage}{%
  \clearpage
  \if@twoside
    \ifodd\c@page
    \else
      \blankpage
      \thispagestyle{empty}
      \newpage
      \if@twocolumn
        \hbox{}\newpage
      \fi
    \fi
  \fi
}
\makeatother

\begin{document}
Text
\chapter{First chapter}
\end{document}

\showlists停止 TeX 运行并显示当前垂直列表。这会写入文件.log,如果\tracingonline设置为正数,也会打印在终端上。

文件摘录.log

### vertical mode entered at line 0
### current page:
\write-{}
\glue(\topskip) 11.0
\rule(0.0+0.0)x*
\penalty 10000
\glue 0.0 plus 1.0fill
\glue 0.0
\glue(\parskip) 0.0 plus 1.0
\glue(\baselineskip) 5.99585
\hbox(7.60416+2.12917)x418.25555, glue set - 0.1209
.\glue(\leftskip) 0.0 plus 1.0fil
.\hbox(0.0+0.0)x0.0
.\OT1/cmr/m/n/10.95 T
.\OT1/cmr/m/n/10.95 h
.\OT1/cmr/m/n/10.95 i
.\OT1/cmr/m/n/10.95 s
.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 p
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 g
.\OT1/cmr/m/n/10.95 e
...
.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 h
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 .
.\glue 4.86665 plus 5.47499 minus 0.40555
.\penalty 10000
.\glue(\parfillskip) 0.0
.\glue(\rightskip) 0.0 plus 1.0fil
\glue 0.0 plus 1.0fill
\glue 0.0
total height 26.72917 plus 1.0 plus 2.0fill
 goal height 595.80026
prevdepth 2.12917, prevgraf 1 line

! OK.

水平居中

正文\hbox开头为:

\hbox(7.60416+2.12917)x418.25555, glue set - 0.1209
.\glue(\leftskip) 0.0 plus 1.0fil
.\hbox(0.0+0.0)x0.0
.\OT1/cmr/m/n/10.95 T

这意味着左边的空间是0pt plus 1fil。由加号\leftskip设置的是居中所需的。\centering and the stretch component1.0fil

该框的结尾是:

.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 .
.\glue 4.86665 plus 5.47499 minus 0.40555
.\penalty 10000
.\glue(\parfillskip) 0.0
.\glue(\rightskip) 0.0 plus 1.0fil

再次,拉伸分量plus 1.0fil来自并需要居中。但最后一个点后有一个粘合:\rightskip\centering

.\glue 4.86665 plus 5.47499 minus 0.40555

这意味着行尾有多余的空白。它来自 之前最后一个点后面的空格\vspace

... that.
\vspace{\fill}

\vspace调用时,段落尚未结束。因此,空格不是直接添加的,而是通过 来添加的。以下段落结尾通常会删除最新的空格,因此不需要删除\vadjust最新行或空行之前的空格。但是,段落结尾看不到之前的空格,并且会出现在输出中。可以通过明确结束段落来解决这个问题:\par\vadjust

... that.\par
\vspace{\fill}

垂直居中

底端看起来不错:

\glue 0.0 plus 1.0fill
\glue 0.0

只存在填充组件。但在上部,我们可以发现对垂直空间的一些额外贡献:

\glue(\topskip) 11.0
\rule(0.0+0.0)x*
\penalty 10000
\glue 0.0 plus 1.0fill
\glue 0.0
\glue(\parskip) 0.0 plus 1.0
\glue(\baselineskip) 5.99585

1. Full `\topskip` is inserted at the top of a page because of the following invisible rule, added by the star form `\vspace*`. Setting it to `0pt` locally fixes this.

2. When a new paragraph starts `\parskip` is added that might have larger values than shown here. Because we have just one paragraph here, setting it to zero is the easiest way.

3. The value for `\baselineskip` comes from the line breaking algorithm. The value is calculated from the setting of `\baselineskip` (`13.6pt`) minus the height of the line (`7.6pt`). This can be suppressed by `\nointerlineskip`.

新的定义\blankpage

\newcommand*{\blankpage}{%
  \begingroup
    \setlength{\topskip}{0pt}%
    \setlength{\parskip}{0pt}%
    \vspace*{\fill}%
    \centering
    \nointerlineskip % suppresses partial \baselineskip above text
    This page would be intentionally left blank if we would not wish
    to inform about that.\par
    \vspace{\fill}%
  \endgroup
  % \showlists
}

摘自.log文件\showlistsfor new \blankpage

### vertical mode entered at line 0
### current page:
\write-{}
\glue(\topskip) 0.0
\rule(0.0+0.0)x*
\penalty 10000
\glue 0.0 plus 1.0fill
\glue 0.0
\glue(\parskip) 0.0
\hbox(7.60416+2.12917)x418.25555, glue set 1.30571fil
.\glue(\leftskip) 0.0 plus 1.0fil
.\hbox(0.0+0.0)x0.0
.\OT1/cmr/m/n/10.95 T
.\OT1/cmr/m/n/10.95 h
.\OT1/cmr/m/n/10.95 i
.\OT1/cmr/m/n/10.95 s
.\glue 3.65 plus 1.825 minus 1.21666
.\OT1/cmr/m/n/10.95 p
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 g
.\OT1/cmr/m/n/10.95 e
...
.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 h
.\OT1/cmr/m/n/10.95 a
.\OT1/cmr/m/n/10.95 t
.\OT1/cmr/m/n/10.95 .
.\penalty 10000
.\glue(\parfillskip) 0.0
.\glue(\rightskip) 0.0 plus 1.0fil
total height 7.60416 plus 1.0fill
 goal height 595.80026
### recent contributions:
\glue 0.0 plus 1.0fill
\glue 0.0
prevdepth 2.12917, prevgraf 1 line

! OK.

支持twocolumn

经过小幅修改后\blankpage也可以使用twocolumn,当文本放在左栏时,但应位于整个文本区域的中央:

\newcommand*{\blankpage}{%
  \begingroup
    \setlength{\topskip}{0pt}%
    \vspace*{\fill}%
    \nointerlineskip % suppresses partial \baselineskip above text
    \hbox to \linewidth{%
      \hbox to \textwidth{%
        \hfill
        This page would be intentionally left blank if we would not wish
        to inform about that.%
        \hfill
      }%
      \hss
    }%
    \vspace{\fill}%
  \endgroup
  % \showlists
}

答案4

加载包中scrlayer可以定义图层页面的样式blank

\usepackage{scrlayer}
\DeclareNewLayer[
    foreground,
    %textarea,% use only the textarea
    contents=\blankpage
  ]{blankpage.fg}
\DeclarePageStyleByLayers{blank}{blankpage.fg}

\KOMAoptions{cleardoublepage=blank}

此页面样式将用于所有空白页。如果您使用open=left或,它也有效twocolumn

\documentclass[
  %open=left,% <- works with open=left
  %twocolumn% <- works in twocolumn mode
]{scrbook}

\newcommand*{\blankpage}{%
  \par\vspace*{\fill}%
  {\centering This page would be intentionally left blank
   if we would not wish to inform about that.\par}
  \vspace{\fill}%
}

\usepackage{scrlayer}
\DeclareNewLayer[
    foreground,
    textarea,% use only the textarea
    contents=\blankpage
  ]{blankpage.fg}
\DeclarePageStyleByLayers{blank}{blankpage.fg}
\KOMAoptions{cleardoublepage=blank}

\usepackage{lipsum}% for dummy text

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{First chapter}
\lipsum[1-2]
\chapter{Second chapter}
\end{document}

请注意,包scrlayer-scrpage已经加载scrlayer。但如果确实需要,您可以scrlayer与过时的scrpage2或一起使用fancyhdr


如果您使用标准类而不是 KOMA-Script 类,您可以加载scrextend以执行相同的操作:

\documentclass[
  %twocolumn% <- works in twocolumn mode
]{book}

\usepackage{scrextend}

\newcommand*{\blankpage}{%
  \par\vspace*{\fill}%
  {\centering This page would be intentionally left blank
   if we would not wish to inform about that.\par}
  \vspace{\fill}%
}

\usepackage{scrlayer}
\DeclareNewLayer[
    foreground,
    textarea,% use only the textarea
    contents=\blankpage
  ]{blankpage.fg}
\DeclarePageStyleByLayers{blank}{blankpage.fg}
\KOMAoptions{cleardoublepage=blank}

\usepackage{lipsum}% for dummy text

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{First chapter}
\lipsum[1-2]
\chapter{Second chapter}
\end{document}

相关内容