Page LayoutPage numbering before toc won't increment

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
k290
Posts: 1
Joined: Mon Jul 08, 2013 12:20 am

Page numbering before toc won't increment

Post by k290 »

I've created an environment for an acknowledgements class. I want the abstract and acknowledgements pages to be in the toc. However, they are both being labeled page "i". The abstract should be page i and the acknowledgement page should be ii. setcounter doesnt help.

I have noticed the same problem occurs if you have two abstracts on separate pages. So I don't think there's a problem with my acknowledgement environment
Here is the minimal working example

Code: Select all

\documentclass[a4paper, 11pt]{report}

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

\usepackage{hyperref}

\title{My Title}
\author{Matt}


\begin{document}

\maketitle

\pagenumbering{roman}

\newpage
\setcounter{page}{1}
\phantomsection
\addcontentsline{toc}{chapter}{Abstract}
\begin{abstract}
The abstract!
\end{abstract}

\newpage
\setcounter{page}{2}
\phantomsection
\addcontentsline{toc}{chapter}{Acknowledgements}
\begin{acknowledgements}
Thanks!
\end{acknowledgements}


\newpage
\setcounter{page}{3}
\phantomsection
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Page numbering before toc won't increment

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

That's because you call \titlepage in your acknowledgements environment. A titlepage has a page number 1. Perhaps simply remove \titlepage and \endtitlepage. If you really would like to fix it like above by changing the page counter, you would get the desired effect if you would write \setcounter{page}{2} after \begin{acknowledgements}. But I don't recommend it.

Stefan
LaTeX.org admin
Post Reply