[Tex/LaTex] Roman numbers in abstract of report class

abstractpage-numberingreportroman numerals

I want to add roman page numbering to all the pages up to the end of the table of contents, apart from the title page. So I did the following, which works, apart from the fact that the abstract does not have any page number.

\begin{document}
\pagenumbering{roman}
\maketitle

\include{abstract}

\tableofcontents

\newpage
\pagenumbering{arabic}

The abstract.tex file contains \begin{abstract} and \end{abstract}.

So I tried to follow the solution to the question here which seems to be asking the exact same question.

And in my abstract tex file I put:

\begin{abstract}
\thispagestyle{plain} 

My abstract...

\end{abstract}

This does add page 'i' to the Abstract page. However, the problem is that subsequent pages in the roman numbering part, such as the table of contents are also getting page 'i' again (that is before changing to arabic numbering).

So essentially I am getting:

Abstract – Page i,
TOC – Page i

While I want

Abstract – Page i,
TOC – Page ii

Why is the counter getting reset to 1 (before changing to arabic numbering) and not continuing from where it was in the abstract?

Best Answer

\pagenumbering - changes should be done after a \clearpage (unless it's the first change right after the start)

\pagenumbering always resets the page counter to 1, see the definition

\def\pagenumbering#1{%
  \global\c@page \@ne \gdef\thepage{\csname @#1\endcsname
   \c@page}}

\global\c@page \@ne is basically Plain TeX for \setcounter{page}{1}

Now the real culprit for report is that it sets titlepage option, i.e. abstract uses the titlepage environment internally, which is defined to reset the page number at the end. Some code from latex.ltx

\if@titlepage
  \newenvironment{abstract}{%
      \titlepage
       \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}
\else
  \newenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        \end{center}%
        \quotation
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi

\if@compatibility
\newenvironment{titlepage}
    {%
      \if@twocolumn
        \@restonecoltrue\onecolumn
      \else
        \@restonecolfalse\newpage
      \fi
      \thispagestyle{empty}%
      \setcounter{page}\z@
    }%
    {\if@restonecol\twocolumn \else \newpage \fi
    }
\else
\newenvironment{titlepage}
    {%
      \if@twocolumn
        \@restonecoltrue\onecolumn
      \else
        \@restonecolfalse\newpage
      \fi
      \thispagestyle{empty}%
      \setcounter{page}\@ne
    }%
    {\if@restonecol\twocolumn \else \newpage \fi
     \if@twoside\else
        \setcounter{page}\@ne
     \fi
    }
\fi

Here the real code

The whole issue can be cured if titlepage is redefined to take care for the special needs of the O.P. by setting \@abstractmode to true and setting the pagestyle and stepping the page counter accordingly, but do no reset of the page counter at the end of the titlepage environment.

\documentclass{report}

\usepackage{etoolbox}
\makeatletter
\newif\if@abstractmode

\renewenvironment{titlepage}
{
  \if@twocolumn
  \@restonecoltrue\onecolumn
  \else
  \@restonecolfalse\newpage
  \fi
  \if@abstractmode
  \thispagestyle{plain}%
  \stepcounter{page}%
  \else
  \thispagestyle{empty}%
  \setcounter{page}\@ne%
  \fi
}%
{\if@restonecol\twocolumn \else \newpage \fi
  \if@twoside\else
  \if@abstractmode
  \else
  \setcounter{page}\@ne%
  \fi
  \fi
}

\AtBeginEnvironment{abstract}{%
  \@abstractmodetrue%
}


\makeatother



\usepackage{blindtext}
\title{Theory of Brontosaurs}
\author{Ann Elk}
\begin{document}
\pagenumbering{roman}
\maketitle
\clearpage
\begin{abstract}
\blindtext[2]
\end{abstract}
\tableofcontents
\cleardoublepage
\pagenumbering{arabic}

\section{First}
\blindtext[10]
\end{document}

enter image description here

enter image description here