2

In the TOC page the "Contents" title appears twice, once at the beginning and once at the end of the table of contents. This problem started when I added the "fancyhdr" commands, since headers and footers are required to appear in the title page as well as in the table of contents page (this is also not working yet). I've tried many suggestions such as:

How do I prevent “Contents” from appearing twice in the header when I use \leftmark and \rightmark with fancyhdr?

How to prevent “CONTENTS” from appearing as a header in ToC

(and many others) but still the problem persists. Here is a short version of the main files I'm using (I only included the most relevant packages for this problem).

The main document (with preamble) looks like this:

    \documentclass[a4paper,10pt,oneside,openany]{book} 
    \usepackage[utf8]{inputenc} % allow specify input encoding
    \usepackage{float}  
    \usepackage[margin=1in]{geometry} % page dimensions
    \usepackage{emptypage} % remove all pages with no text 
    \usepackage{tocloft} 

    % Style customization for headers and footers 
    \usepackage{fancyhdr} 
    \pagestyle{fancy} 
    \fancyhf{} % clears the header and footer
    \lhead{Title goes here} % left side of the header
    \rhead{\today\ } % right side of the header
    \lfoot{Document \#: FFFFF } 
    \cfoot{\thepage} % center of the footer

    % Extra level of sections & include them in TOC
    \setcounter{secnumdepth}{5} 
    \setcounter{tocdepth}{5} 

    % Commands: 
    % Eliminate numbering on titles 
    \renewcommand{\chaptername}{} 
    \renewcommand{\thechapter}{} 
    \renewcommand{\thesection}{} 
    \renewcommand{\thesubsection}{} 
    \renewcommand{\thesubsubsection}{} 
    \renewcommand{\theparagraph}{} 
    \renewcommand{\thesubparagraph}{} 

    % Trying to fix double Contents title (not working yet)
    \makeatletter 
    \renewcommand\tableofcontents{% 
         \chapter*{\contentsname 
             \@mkboth{% 
                 \MakeUppercase\contentsname}{}} 
         \@starttoc{toc}% 
         }  
    \makeatother 

    \begin{document} 

    \begin{titlepage} 
    \titlepage\thispagestyle{fancy} 
    \noindent 
    {\huge\bf Title goes here }\\ 
    \rule{\textwidth}{2pt} % horizontal line 
    \noindent 
    {\huge\bf Sub-title goes here}\\ 
    \end{titlepage} 
    \renewcommand{\cfttoctitlefont}{\hfill\normalfont\Large\bfseries\MakeUppercase} 
    \renewcommand{\cftaftertoctitle}{\hfill\noindent} 
    \renewcommand{\contentsname}{TABLE OF CONTENTS} 
    \tableofcontents\thispagestyle{fancy} 
    \begingroup 
    \tableofcontents 
    % delete white pages 
    \let\cleardoublepage\clearpage 
    \let\cleardoublepage\clearpage 
    \endgroup 

    \include{./Intro/Intro} 
    \include{./Chapter1/Chapter1} 
    \include{./Chapter2/Chapter2} 


    \end{document} 

The Intro.tex has for now only:

    \chapter{Intro}

Chapter1.tex and Chapter2.tex respectively look like this:

    \chapter{Chapter 1}
    \section{Section 1}
0

1 Answer 1

2

First, it is not the header and second , this has nothing to do with fancyhdr.

You have called \tableofcontents twice:

\tableofcontents\thispagestyle{fancy}
\begingroup
\tableofcontents

Remove one of them (the second one):

\tableofcontents\thispagestyle{fancy}
\begingroup
%\tableofcontents      %%<---remove

You will get

enter image description here

BTW, remove these lines too:

\makeatletter
    \renewcommand\tableofcontents{%
         \chapter*{%\contentsname
             \@mkboth{%
                 \MakeUppercase\contentsname}{}}
         \@starttoc{toc}%
         }
    \makeatother
2
  • Great! Thank you so very much Harish! That fixed the problem. I was confused because I thought the line \tableofcontents\thispagestyle{fancy} was used to only add the style for the TOC page. I really appreciate all your help. =] Sep 7, 2015 at 16:58
  • @StalinRios You are welcome. Please remember that you can also accept the answer if it helped solve your problem by clicking the pale green check mark below the vote count.
    – user11232
    Sep 7, 2015 at 22:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .