将页眉放在页面顶部(现在位于上一页的底部)

将页眉放在页面顶部(现在位于上一页的底部)

这个问题基于此回答。从下面的这个例子中可以看出,当摘要长度超过一页时,标题“摘要”被推到上一页的底部。当以下内容长度超过一页时,我需要将标题放在页面顶部(就在以下内容开始之前)。我该如何实现?

\documentclass[oneside]{book}
\usepackage{xparse}
\usepackage[english]{babel}
\usepackage{blindtext}

\providecommand{\abstractname}{Abstract}
\providecommand{\acknowledgmentname}{Acknowledgment}

\ExplSyntaxOn
\NewDocumentEnvironment{abstract}{O{0}O{\c_pushpen_thesis_emptypage_tl}}
 {
  \xxxx_thesis_commonenv_start:n { \abstractname }
 }
 {
  \xxxx_thesis_commonenv_end:nn { #1 } { #2 }
 }
\NewDocumentEnvironment{acknowledgment}{O{0}O{\c_pushpen_thesis_emptypage_tl}}
 {
  \xxxx_thesis_commonenv_start:n { \acknowledgmentname }
 }
 {
  \xxxx_thesis_commonenv_end:nn { #1 } { #2 }
 }

\cs_new_protected:Nn \xxxx_thesis_commonenv_start:n
 {
  \clearpage
  \thispagestyle{empty}
  \vspace*{\fill}
  \begin{center}
  \setlength{\parskip}{0pt}% Why? It should always be zero!
  \huge\itshape #1
  \end{center}
  \par\bigskip
 }

\cs_new_protected:Nn \xxxx_thesis_commonenv_end:nn
 {
  \par\vspace*{\fill}
  \clearpage
  \prg_replicate:nn { #1 } % do #1 times the following
   {
    \vspace*{\fill}\thispagestyle{empty}
    {\centering #2\par}
    \vspace*{\fill}
    \clearpage
   }
 }

\tl_const:Nn \c_pushpen_thesis_emptypage_tl
 {
  This~page~intentionally~left~blank
 }

\ExplSyntaxOff

\begin{document}

\begin{abstract}[2][Nothing here]
This is the text of the abstract.
This is the text of the abstract.
This is the text of the abstract.
This is the text of the abstract.

More than one paragraph, too!
More than one paragraph, too!
More than one paragraph, too!
More than one paragraph, too!
More than one paragraph, too!

\blindtext[10]
\end{abstract}

\begin{acknowledgment}
The author is grateful to his cat
for not walking on the keyboard
while jiofoaijo dwjoioa ewdiroenwe
\end{acknowledgment}

\chapter{This is where everything begins}

Some text.

\end{document}

答案1

您可以通过\vspace*{\fill}在环境语法中进行注释来实现这一点。以下是您稍加修改后的代码。

\documentclass[oneside]{book}
\usepackage{xparse}
\usepackage[english]{babel}
\usepackage{blindtext}

\providecommand{\abstractname}{Abstract}
\providecommand{\acknowledgmentname}{Acknowledgment}

\ExplSyntaxOn
\NewDocumentEnvironment{abstract}{O{0}O{\c_pushpen_thesis_emptypage_tl}}
 {
  \pushpen_thesis_commonenv_start:n { \abstractname }
 }
 {
  \pushpen_thesis_commonenv_end:nn { #1 } { #2 }
 }
\NewDocumentEnvironment{acknowledgment}{O{0}O{\c_pushpen_thesis_emptypage_tl}}
 {
  \pushpen_thesis_commonenv_start:n { \acknowledgmentname }
 }
 {
  \pushpen_thesis_commonenv_end:nn { #1 } { #2 }
 }

\cs_new_protected:Nn \pushpen_thesis_commonenv_start:n
 {
  \clearpage
  \thispagestyle{empty}
%   \vspace*{\fill} %% 
  \begin{center}
  \setlength{\parskip}{0pt}% Why? It should always be zero!
  \huge\itshape #1
  \end{center}
  \par
 }

\cs_new_protected:Nn \pushpen_thesis_commonenv_end:nn
 {
  \par\vspace*{\fill}
  \clearpage
  \prg_replicate:nn { #1 } % do #1 times the following
   {
    \vspace*{\fill}\thispagestyle{empty}
    {\centering #2\par}
    \vspace*{\fill}
    \clearpage
   }
 }

\tl_const:Nn \c_pushpen_thesis_emptypage_tl
 {
  This~page~intentionally~left~blank
 }

\ExplSyntaxOff


\begin{document}

\begin{abstract}[0][Nothing here]
This is the text of the abstract.
This is the text of the abstract.
This is the text of the abstract.
This is the text of the abstract.

More than one paragraph, too!
More than one paragraph, too!
More than one paragraph, too!
More than one paragraph, too!
More than one paragraph, too!

\blindtext[10]
\end{abstract}

\begin{acknowledgment}
The author is grateful to his cat
for not walking on the keyboard
while jiofoaijo dwjoioa ewdiroenwe
\end{acknowledgment}

\chapter{This is where everything begins}

Some text.

\end{document}

相关内容