# Page numbering error in table of contents

I'm preparing my thesis report. My table of contents starts from roman page number (iii) and has a total of 3 pages. But unfortunately the last page of toc shows page number (iii) again. Same is the case for the lof (3 pages). I am using \documentclass[a4paper,12pt]{report}. I'm a beginner in LaTeX, so please help me.

\documentclass[a4paper,12pt]{report}

\setcounter{tocdepth}{3}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents
\pagenumbering{roman}\setcounter{page}{3}
\clearpage

\addcontentsline{toc}{chapter}{Summary}
\pagenumbering{roman}
\setcounter{page}{6}
\chapter*{Summary}
\clearpage

\listoffigures
\pagestyle{plain}
\pagenumbering{roman}
\setcounter{page}{7}
\addcontentsline{toc}{chapter}{\listfigurename}
\clearpage

\listoftables
\pagenumbering{roman}
\setcounter{page}{10}
\addcontentsline{toc}{chapter}{\listtablename}
\clearpage

• All those instances of \pagenumbering and \setcounter are quite possibly missleading and disturbing you and your document. LaTeX is very very capable of counting pages, no need to number them yourself. I would kick out all of this lines. Please also have a look at How to use pagenumbering in the document? – Johannes_B Jul 27 '15 at 11:01
• welcome to tex.sx. you are resetting the page counter to 3 after \tableofcontents. once the numbering starts, you really shouldn't have to reset it until you change to arabic for the body of the document. and issuing \addcontentsline for the summary before setting the page number will almost certainly result in the wrong page number in the toc. it's almost always better to specify \addcontentsline immediately after the \chapter line for that element. – barbara beeton Jul 27 '15 at 11:06
• As it stands this example will fail to compile; there is only a preamble yet, filled with some content of your thesis. Can you please complete your example to a fully working, but minimal LaTeX document (starting with \documentclass and concluding with \end{document}) that showcases your error? even if you alredy got the solution. – Ruben Jul 27 '15 at 11:25
• You can also force a new page (without generating the "there is no page" error message) using \par\rule{0pt}{\textheight} – John Kormylo Jul 27 '15 at 16:32
• I suggest to use \usepackage{tocbibind} -- this will yield many of the \addcontentsline code above as unnecessary – user31729 Jul 28 '15 at 6:14

## 2 Answers

You shouldn't give repeated \pagenumbering{roman} commands: LaTeX just knows the page numbers.

Be careful to issue the \addcontentsline command at the right time, that is, after a new page has been started.

\documentclass[a4paper,12pt]{report}

\setcounter{tocdepth}{3}

\begin{document}

\cleardoublepage % if some contents comes before
\pagenumbering{roman}\setcounter{page}{3}
\addcontentsline{toc}{chapter}{Contents}
\tableofcontents

\cleardoublepage

\addcontentsline{toc}{chapter}{Summary}
\chapter*{Summary}

\cleardoublepage

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\cleardoublepage

\addcontentsline{toc}{chapter}{\listtablename}
\listoftables

\cleardoublepage

\pagenumbering{arabic}

\def\one{%
\chapter{Something}
\section{A}
some text
\section{A}
some text
\begin{figure}
\caption{Whatever}
\end{figure}
\section{A}
some text
\begin{table}
\caption{Whatever}
\end{table}
}
\def\many{\one\one\one\one\one\one\one\one\one\one\one\one\one\one\one}

\many % make as much contents as to produce three pages in the toc

\end{document}


You can vastly simplify the input by using the tocbibind package and the book class.

\documentclass[a4paper,12pt,oneside]{book}
\usepackage{tocbibind}

\setcounter{tocdepth}{3}
\pagestyle{plain} % this is what report uses

\begin{document}

\frontmatter
\setcounter{page}{3}

\tableofcontents

\chapter{Summary}

\listoffigures

\listoftables

\mainmatter

\def\one{%
\chapter{Something}
\section{A}
some text
\section{A}
some text
\begin{figure}
\caption{Whatever}
\end{figure}
\section{A}
some text
\begin{table}
\caption{Whatever}
\end{table}
}
\def\many{\one\one\one\one\one\one\one\one\one\one\one\one\one\one\one}

\many

\end{document}


Got the solution! I rearranged the lines in the following order:

\setcounter{tocdepth}{3}
\addcontentsline{toc}{chapter}{Contents}
\pagenumbering{roman}\setcounter{page}{3}
\tableofcontents

• This is bound to fail. Please read at How to use pagenumbering in the document? why a cleardoublepage is always necessary to ensure a right hand page (or rather the blank page before). If you set the pagenumber to an even page, you have to ensure it really is on a left hand page. LaTeX would take care of it, but manually changing stuff means manually fixing stuff. – Johannes_B Jul 27 '15 at 11:36