TransWikia.com

Put the header at top of page (which is now at bottom of previous page)

TeX - LaTeX Asked on January 3, 2021

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!
  hugeitshape #1
  end{center}
  parbigskip
 }

cs_new_protected:Nn xxxx_thesis_commonenv_end:nn
 {
  parvspace*{fill}
  clearpage
  prg_replicate:nn { #1 } % do #1 times the following
   {
    vspace*{fill}thispagestyle{empty}
    {centering #2par}
    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}

One Answer

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!
  hugeitshape #1
  end{center}
  par
 }

cs_new_protected:Nn pushpen_thesis_commonenv_end:nn
 {
  parvspace*{fill}
  clearpage
  prg_replicate:nn { #1 } % do #1 times the following
   {
    vspace*{fill}thispagestyle{empty}
    {centering #2par}
    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}

Answered by Tanvir on January 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP