1

I have one problem with the page number in Table of Content. My settings are:

\documentclass[12pt,a4paper]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{\thepage}
\pagestyle{fancy}

\begin{document}


\begingroup
%\hypersetup{hidelinks}
\cleardoublepage
  \pagestyle{fancy}
\clearpage\setcounter{page}{3}
\tableofcontents
 \cleardoublepage
\endgroup

\newpage
\addcontentsline{tableofcontents}{chapter}{\listfigurename}
\listoffigures
\newpage
\addcontentsline{tableofcontents}{chapter}{\listtablename}
\listoftables


\end{document}

But the page number in TOC and List of Figure and tables are like: odd page in the bottom center, and even page in top center. What I want is all page numbers in top center. Can anyone tell me what is wrong here, why it does not work. Thanks a lot.

  • Welcome to TeX.SX! Please add \documentclass{yourclass} to your code. You can use tocbibind package for the addition to the toc and the ToC/LoF/Lot commands use an implicit \thispagestyle{plain} – user31729 Jul 2 '15 at 9:01
1

This changes the plain page style globally (since this is applied by \tableofcontents etc.)

I additionally removed some strange grouping/unnecessary \clearpage commands and added \usepackage{tocbibind} for clean addition to ToC

\documentclass[a4paper,12pt]{report}
\usepackage{fancyhdr}
\usepackage[nottoc]{tocbibind}

\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{\thepage}
}

\usepackage{blindtext}

\begin{document}


\setcounter{page}{3}  %% Why??????
\tableofcontents
\listoffigures
\listoftables

\blinddocument


\end{document}

enter image description here enter image description here

Edit Dotted toc line for LoF and LoT -- I don't recommend this!!

\documentclass[a4paper,12pt]{report}
\usepackage{fancyhdr}
%\usepackage[nottoc]{tocbibind}  

\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{\thepage}
}

\usepackage{blindtext}

\makeatletter
\newcommand*\l@fakesection{\@dottedtocline{1}{0em}{2.3em}}
\makeatother

\usepackage{hyperref}


\begin{document}


\setcounter{page}{3}  %% Why??????
\tableofcontents

\clearpage
\phantomsection
\addcontentsline{toc}{fakesection}{\bfseries\listfigurename}
\listoffigures

\clearpage
\phantomsection
\addcontentsline{toc}{fakesection}{\bfseries\listtablename}
\listoftables

\clearpage
\pagestyle{fancy}
\blinddocument


\end{document}
  • Thanks a lot Christian Hupfer ...This really works...you saved me from many days of working....thanks a lot – user2307344 Jul 2 '15 at 9:22
  • @user2307344: If you want to keep the page headings for sections/chapters, we've to reenable them of course. Happy TeXing! – user31729 Jul 2 '15 at 9:25
  • @ Christian Hupfer , in fact I need this for my whole document. I managed with other parts, the TOC is the only part left. now they are all solved , thanks again – user2307344 Jul 2 '15 at 9:29
  • @ Christian Hupfer Do you know how can I add dot after List of Table and Figures? Also delete the first small contents ..it is not needed here. thanks – user2307344 Jul 2 '15 at 9:47
  • @user2307344: Those are other questions. With dot you mean the dotted line? The ToC can be removed from ToC with the nottoc option -- see my edited answer – user31729 Jul 2 '15 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.