2

I am trying to create a new class for my thesis. I defined a \NewDocumentEnvironment for the Abstract page.

The usage is as follows (#1 m, #2 o, #3 O):

\abstract{Your abstract}[number of blank pages][comment~on~the~last~page].

For example, \abstract{content}[3] gives a 4 page document, first page is with conent, rest two pages blank, fourth page shows the default This~page~is~intentionally~left~empty! message.

Now, let's say, I want to have my Acknowledgement page to be of the same style. One option is to copy everything and rename it. But what is a better option? Can I create one \NewDocumentEnvironment which will be used in both abstract and acknowledgement?

Class (testtwo.cls)

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{testtwo} [2017/05/11 v0.1 A class to write PhD thesis]

\LoadClass{book}

\usepackage{xparse} % http://ctan.org/pkg/xparse
%% Abstract
{}
\ExplSyntaxOn
\NewDocumentEnvironment{abstract}{m o O{This~page~is~intentionally~left~empty!}} % https://tex.stackexchange.com/a/30992/38244
{
    \pagestyle{empty}
    \null\vfil
    \begin{center}
        \setlength{\parskip}{0pt}
        {\huge{\textit{Abstract}} \par}
        \bigskip
    \end{center}
        {\normalsize #1 \par}
        \vspace*{\fill}

    \newcount\tmp 


    \IfNoValueTF{#2} 
    {   %#2 is nothing 
        \pagebreak
    } 
    { % #2 is something
        {
            \tmp=0 % https://tex.stackexchange.com/a/89015/38244
            \loop
            \advance\tmp by 1
            \null\newpage 
            \ifnum\tmp<#2
            \repeat


        \IfNoValueTF{#3} 
        { %#3 is nothing!
            \pagebreak
        } 
        {   %#3 is something!
            \pagebreak
            \topskip0pt % https://tex.stackexchange.com/a/2327/38244
            \vspace*{\fill}
            \hspace*{\fill}
            \textit{#3} % Not sure why spaces aren't coming!
            \hspace*{\fill}
            \vspace*{\fill}
        }
        %#3 ends here   
        }
    }


}
{}
\ExplSyntaxOff

MWE (testtwo.tex)

\documentclass{testtwo}

\begin{document}
    \abstract{something}[3]%[]
\end{document}
1
  • 4
    environments have the syntax \begin{zzz}..\end{zzz} not \zzz{...} either declare it as a command or an enviornment, but use it in whichever way you declare Commented May 11, 2017 at 18:40

1 Answer 1

3

You should decide either for a command or an environment.

The best syntax, in my opinion, is with an environment.

\documentclass[oneside]{book}
\usepackage{xparse}

\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\bigskip
 }

\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}[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!
\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}

The common parts are done with some macros which you can pass the title to.

2
  • There seems a problem when the content exceeds one page. The header is moved to the bottom of the previous page.
    – hola
    Commented Jul 17, 2020 at 19:23
  • Asked this follow-up question: tex.stackexchange.com/q/553972/38244
    – hola
    Commented Jul 17, 2020 at 19:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .