# Why is the last page of ToC treated as page 1 of the document?

I have pulled my hair on this one far too long, so now I'm asking for help as to where I've done things wrong.

Minimal Working Example:

\documentclass[12pt,a4paper,twoside]{report}

\usepackage{newxjobb}
\usepackage[swedish]{babel}   % date format and hyphenation rules(?)
\selectlanguage{swedish}

\usepackage{blindtext}

%--------------------
% Four subsections
\usepackage{titlesec}
\setcounter{secnumdepth}{4}

% Fugly hack to remove section numbers in ToC
\renewcommand{\thesection}{}
\renewcommand{\thesubsection}{}
\renewcommand{\thesubsubsection}{}

%-------------------- Remove section numbering
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother
%--------------------

\begin{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{roman}
\pagestyle{empty} % Empty until the abstract

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page

\hfil\hspace*{-4mm}
\begin{minipage}{100mm}
\center {
\vbox to 56mm{\vfil\LARGE\textbf{Shiny Title}}}
\vspace*{2.5mm}
\textbf{Things and stuff} \\
\vspace*{7mm}
\textbf{\large Mr. Name Nameson} \\
City 2019 \\
\vspace*{7mm}
Should you fancy something erronious, drop a mail: \\
www@example.com
\end{minipage}\hfil
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\clearpage

\thispagestyle{empty}
\setcounter{page}{0}
\tableofcontents

%-------------------- Document start
\pagenumbering{arabic}
\pagestyle{fancy}

\chapter{Foo}
\blindtext
\subsection{asdf0}
\subsection{asdf1}
\subsection{asdf2}
\subsection{asdf3}
\subsection{asdf4}
\subsection{asdf5}
\subsection{asdf6}
\subsection{asdf7}
\subsection{asdf8}
\subsection{asdf9}

\chapter{Bar}
\blindtext[2]
\subsection{asdf0}
\subsection{asdf1}
\subsection{asdf2}
\subsection{asdf3}
\subsection{asdf4}
\subsection{asdf5}
\subsection{asdf6}
\subsection{asdf7}
\subsection{asdf8}
\subsection{asdf9}

\chapter{Gazonk}
\blindtext[3]
\subsection{asdf0}
\subsection{asdf1}
\subsection{asdf2}
\subsection{asdf3}
\subsection{asdf4}
\subsection{asdf5}
\subsection{asdf6}
\subsection{asdf7}
\subsection{asdf8}
\subsection{asdf9}

\end{document}


Produces a PDF with this content:

The package "newxjobb" is a non-standard package (not made by me) that some students use at my faculty so I'm adding it here as well in case the error is in there. This package has always been used with English documents, my document is the first one using Swedish. If that's the cause of the problem I do not know.

Package "newxjobb":

%  Package file with options making me feel better...
%  (Author: Stefan Langemark)
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{newxjobb}[2018/11/16 *** To be reviewed! ***]

\RequirePackage{parskip}
\RequirePackage{geometry}
\RequirePackage[T1]{fontenc} % ... the following line doesn't make much sense
% without this one
\RequirePackage[utf8]{inputenc}
\RequirePackage{fancyhdr}

%
%--------------------------------
%    Paper layout
%    (no room for margin notes)
%--------------------------------
%
% paper=b5paper,
\geometry{
paperwidth = 165mm, paperheight = 240mm,
%   paper = a4paper,
total = {130mm,200mm},
%  marginparsep = 2mm,
%  marginparwidth = 15mm,
includemp = false,
%twosideshift = 10pt
}
\addtolength{\headheight}{10pt} % ??? (use "\geometry{...}" instead!)

%-------------------------------
%    Header/Footer
%-------------------------------
\pagenumbering{arabic}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhf{}
\fancyhead[RO]{\bfseries\leftmark}
\fancyhead[LE]{\bfseries\rightmark}
\fancyhead[RO,LE]{\bfseries\thepage}
\pagestyle{fancy}
\fancypagestyle{headings}{%
\fancyhf{}%
\renewcommand{\headrulewidth}{0pt}
}

%
%-------------------------------------
%  Redefine {chapter,section}mark to
%  remove ugly all-uppercase
%-------------------------------------
%
% feck off
\renewcommand{\chaptermark}[1]{\markboth{\bfseries ARNE}{HEJHEJ}}
\renewcommand{\sectionmark}[1]{\markright{\bfseries \chaptername\ \thechapter.\enspace #1}}

%
%-------------------------------
%  Redefining section styles
%  to suit parskip > 0
%-------------------------------
%
%\addtocounter{secnumdepth}{1}% Number subsubsections too
%\addtocounter{tocdepth}{1}%    Include subsections in table of contents.

\renewcommand\section{\@startsection%
{section}%
{1}%
{\z@}%
{-2.5ex \@plus -1ex \@minus -.2ex}%
{1.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}%
}
\renewcommand\subsection{\@startsection%
{subsection}%
{2}%
{\z@}%
{-2.25ex\@plus -1ex \@minus -.2ex}%
{0.5ex \@plus .2ex}%
{\normalfont\large\bfseries}%
}
\renewcommand\subsubsection{\@startsection%
{subsubsection}%
{3}%
{\z@}%
{-2.25ex\@plus -1ex \@minus -.2ex}%
{0.1pt \@plus .2ex}%
{\normalfont\mdseries\large\itshape}%
}

%
%
\renewcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname}%
\markboth{\contentsname}{\contentsname}%
\@starttoc{toc}%
\if@restonecol\twocolumn\fi
}
\renewcommand\listoffigures{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listfigurename}%
\markboth{\listfigurename}{\listfigurename}%
\@starttoc{lof}%
\if@restonecol\twocolumn\fi
}
\renewcommand\listoftables{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\listtablename}%
\markboth{\listtablename}{\listtablename}%
\@starttoc{lot}%
\if@restonecol\twocolumn\fi
}
%
%-------------------------------------------
%  Chapter (stolen from Kluwer book style)
%-------------------------------------------
%
\newcommand*\chapnumber{% chapter number
\fontsize{50}{60}%
\usefont{T1}{lmr}{bx}{n}%
}
\newcommand*\chaptitle{% chapter title
\fontsize{20}{24}%
\usefont{T1}{lmr}{bx}{n}%
}

\def\bigraggedleft{\leftskip0pt plus1fil\relax}

\def\@makechapterhead#1{%\null\vskip-5pc
\vbox to 8pc{\hbox to\textwidth{\hfill\chapnumber\thechapter}
\hyphenpenalty=10000 % No hyphenation in chapter heads
\vskip8pt
\hrule height 2.5pt
\vskip12pt\vskip-\parskip
\def\\ {\vskip-\parskip}\parfillskip=0pt
\bigraggedleft
\chaptitle{\def\\ {\vskip-\parskip}#1}\vskip1sp
\vfill}}

\def\@makeschapterhead#1{\vbox to 7.5pc{
\hrule height 1.5pt
\hyphenpenalty=10000 % No hyphenation in chapter heads
\vskip12pt\vskip-\parskip
\def\\ {\vskip-\parskip}\parfillskip=0pt
\bigraggedleft
\chaptitle{#1}\vskip1sp\vfill}}
% END newxjobb-package


I am blind as to why the numbering problem occurs, and now I've given up searching for it.

Have I made an obvious error?

• Add \cleardoublepage before \pagenumbering Mar 1, 2019 at 11:11
• I spent about five minutes writing my question, and you nailed it in less than 40 seconds. Well done, I'm impressed. Please add it as an answer so I can accept it.
– bos
Mar 1, 2019 at 11:15
• You also should replace your \clearpage before the \tableofcontents command with a \cleardoublepage too Mar 1, 2019 at 11:17
• @koleygr: Why is that?
– bos
Mar 1, 2019 at 11:18
• You are using a double sided document (twoside in your documentclass options ,means that you want each chapter to start in an odd page, different margins for odd and even pages and such things, so that the final document can be printed as a book with margins left and right -when opened in a page-). This means that table of contents would be really ugly if started on a left page just after the title page... Like chapters, it should start on a right page Mar 1, 2019 at 11:23

## 1 Answer

You have

\begin{document}
\pagenumbering{roman}
\pagestyle{empty} % Empty until the abstract

% Title page

\hfil\hspace*{-4mm}
\begin{minipage}{100mm}
\center {
\vbox to 56mm{\vfil\LARGE\textbf{Shiny Title}}}
\vspace*{2.5mm}
\textbf{Things and stuff} \\
\vspace*{7mm}
\textbf{\large Mr. Name Nameson} \\
City 2019 \\
\vspace*{7mm}
Should you fancy something erronious, drop a mail: \\
www@example.com

\end{minipage}\hfil

\clearpage

\thispagestyle{empty}
\setcounter{page}{0}
\tableofcontents

%-------------------- Document start
\pagenumbering{arabic}
\pagestyle{fancy}


which has several inconsistencies.

The first \pagenumbering{roman} should better be \pagenumbering{Alph} (you'll understand why when you'll add hyperref).

Next, change \setcounter{page}{0} to \clearpage\pagenumbering{roman} and \pagenumbering{arabic} to \clearpage\pagenumbering{arabic}.

What's the problem? Your \pagenumbering{arabic} is found before TeX has ejected the last page of the table of contents, so that page gets numbered 1.

Also \pagestyle{fancy} should be moved before \tableofcontents.

By the way, if you don't want to number sections and subsections, it's much easier to issue

\setcounter{secnumdepth}{0} % only numbers chapters


Here's an edited version.

\documentclass[12pt,a4paper,twoside]{report}

\usepackage{newxjobb}
\usepackage[swedish]{babel}   % date format and hyphenation rules(?)

\usepackage{blindtext}

%--------------------
% Four subsections
\usepackage{titlesec}
\setcounter{secnumdepth}{0}

\begin{document}

\pagenumbering{Alph}
\pagestyle{empty} % Empty until the abstract

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page

\begin{center}
{\LARGE\textbf{Shiny Title}\\}
\textbf{Things and stuff} \\[7mm]
{\large\textbf{Mr. Name Nameson} \\}
{\large City 2019 \\[7mm]}
Should you fancy something erroneous, drop a mail: \\
www@example.com
\end{center}

\clearpage
\pagenumbering{roman}

\pagestyle{fancy}

\tableofcontents

%-------------------- Document start

\clearpage
\pagenumbering{arabic}

\chapter{Foo}
\blindtext
\subsection{asdf0}
\subsection{asdf1}
\subsection{asdf2}
\subsection{asdf3}
\subsection{asdf4}
\subsection{asdf5}
\subsection{asdf6}
\subsection{asdf7}
\subsection{asdf8}
\subsection{asdf9}

\chapter{Bar}
\blindtext[2]
\subsection{asdf0}
\subsection{asdf1}
\subsection{asdf2}
\subsection{asdf3}
\subsection{asdf4}
\subsection{asdf5}
\subsection{asdf6}
\subsection{asdf7}
\subsection{asdf8}
\subsection{asdf9}

\chapter{Gazonk}
\blindtext[3]
\subsection{asdf0}
\subsection{asdf1}
\subsection{asdf2}
\subsection{asdf3}
\subsection{asdf4}
\subsection{asdf5}
\subsection{asdf6}
\subsection{asdf7}
\subsection{asdf8}
\subsection{asdf9}

\end{document}


Last comment: erronious is, er, erroneous.

• Doesn't report support frontmatter and mainmatter? Imo they make more symantic sense than pagenumbering even though they sort of do the same Mar 1, 2019 at 12:45