0

This question is based on this answer. As it can be seen from this example below, the header "Abstract" is pushed to the bottom of the previous page when the abstract is longer than one page. I would require that the header is at the top of the page (just before the following content starts) when the following content is more than one page long. How can I achieve that?

\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

You can achieve that by commenting \vspace*{\fill} in the environment syntax. Following is your code with little modification.

\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}
3
  • This actually has the problem that the heading is always forced to the top. What I want is, (i) If content is less than a page then title will be vertically aligned with rest of the content (ii) If content is more than a page then title will be on top of first page
    – hola
    Jul 20 '20 at 11:40
  • I do not understand what you mean by 'title will be vertically aligned with content'. Isn't it at the moment when you compile?
    – Tanvir
    Jul 20 '20 at 11:51
  • Yep, when the content is less than a page the formatting is perfect. My only problem is how to set title at top when content is more than a page.
    – hola
    Jul 21 '20 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.