# Number of pages are the same in TOC

I followed these two questions to get the page in roman numbers and add these pages to toc, How can I add abstract and acknowledgement pages into the table of contents? and Roman numeral page numbering.

I modified some code and get

\documentclass[12pt,a4paper]{memoir}

\title{My Thesis Title}
\author{Me, The Author}

% Define the (unnumbered) title page layout here
\newcommand{\mytitlepage}{
\pagenumbering{alph}
\thispagestyle{empty}
\beforepartskip
\begin{center}
\thetitle

\theauthor
\end{center}
\afterpartskip
\newpage
}

% Define the abstract page layout (numbered iii) here
\newcommand{\abstractpage}{
\frontmatter
\setcounter{page}{3}
\pagestyle{plain}
\begin{center}
Abstract: \thetitle
\end{center}

\theabstract
\newpage
}

% Define the abstract page contents here
\newcommand{\theabstract}{
Abstract content goes here.
}

% Define the acknowledgement page layout (numbered ii) here
\newcommand{\acknowledgementpage}{
\frontmatter
\setcounter{page}{2}
\pagestyle{plain}
\begin{center}
Acknowledgement
\end{center}
}

\begin{document}
\mytitlepage
\acknowledgementpage
\abstractpage
\tableofcontents*
\mainmatter
\chapter{One}
This is chapter 1.
\end{document}

I suppose to get number of page of Acknowledgement, Abstract, and TOC as ii, iii , iv, respectively, However, I get ii, iv, iv.

Any idea for this issue?

Thanks.

This problem is solved by placing the \addcontentsline command within your definition of the page layouts:

\documentclass[12pt,a4paper]{memoir}

\title{My Thesis Title}
\author{Me, The Author}

% Define the (unnumbered) title page layout here
\newcommand{\mytitlepage}{
\pagenumbering{alph}
\thispagestyle{empty}
\beforepartskip
\begin{center}
\thetitle

\theauthor
\end{center}
\afterpartskip
\newpage
}

% Define the acknowledgement page layout (numbered ii) here
\newcommand{\acknowledgementpage}{
\frontmatter
\setcounter{page}{2}
\pagestyle{plain}
\begin{center}
Acknowledgement
\end{center}
}

% Define the abstract page contents here
\newcommand{\theabstract}{
Abstract content goes here.
}

% Define the abstract page layout (numbered iii) here
\newcommand{\abstractpage}{
\frontmatter
\setcounter{page}{3}
\pagestyle{plain}
\begin{center}
Abstract: \thetitle
\end{center}

\theabstract
\newpage
}

\begin{document}
\mytitlepage
\acknowledgementpage
\abstractpage