3

I am using LaTeX to make a document and I want to hide the header and footer on the page that contains the table of contents.

How can i do this?

I am new to LaTeX, I already searched for an answer but have not found anything useful for me.

This is the code that I use:

\documentclass{report}
\usepackage{textcomp}
\usepackage[hidelinks]{hyperref}
\usepackage{tocloft} % the tocloft package lets you redefine the Table of Contents (ToC)
  \renewcommand\cftchappresnum{Chapter } % prefix "Chapter " to chapter number in ToC
  \cftsetindents{chapter}{0em}{8em}      % set amount of indenting
  \cftsetindents{section}{2em}{6em}
% Macros to redefine numbering of appendix sections (and to
%   reset numbering when not in per-chapter area appendix)
\newcommand\normalsecnums{%
    \renewcommand\thesection{\thechapter.\arabic{section}}}
\let\origchapter\chapter
\renewcommand{\chapter}[1]{\normalsecnums
    \origchapter{#1}}
\newcommand\appsecnums{%   % execute this command before entering appendix area
    \setcounter{section}{0}
    \renewcommand\thesection{\appendixname~\Alph{section}}}
\usepackage[lmargin=2cm,rmargin=2.5cm,tmargin=2cm,bmargin=2cm]{geometry}
\usepackage{fancyhdr, lastpage}
\pagestyle{fancy}
    \fancyhead[L]{Company name\\ Version 1.0}
    \fancyhead[R]{Date: \today\\ Page: \thepage\ of \pageref{LastPage}}

\fancypagestyle{plain}{
    \fancyhf{}
    \fancyhead[L]{Company name\ Version 1.0}
    \fancyhead[R]{Date: \today\\ Page: \thepage\ of \pageref{LastPage}}
    }

\begin{document}

\begin{titlepage}
\begin{center}
\vspace*{\fill}
    \Large \textbf{Document Title}

    \section*{Author:}
    MyName
\vspace*{\fill}
\end{center}

\end{titlepage}


\newpage
\begin{titlepage}
    \tableofcontents
\end{titlepage}
  • Welcome to TeX.sx! Your post was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Nov 13 '13 at 15:09

1 Answers1

3

To remove the header & footer completely, you can make the page style in use equivalent to the empty page style:

\begingroup
\makeatletter% Allow use of restricted @ in control sequences
\let\ps@fancy\ps@empty% Make fancy page style equivalent to empty page style
\tableofcontents
\clearpage
\endgroup

The use of \begingroup...\endgroup localizes the page style change to only pertain to the \tableofcontents. \let<csnameA><csnameB> copies the definition of <csnameB> over that of <csnameA>, making them equivalent (note that this is different from something like \def<csnameA>{<csnameB>}.

Finally, it is important to know that page styles are applied at page shipout. As such, the redefinition of the fancy page style should at least survive until the page is cleared, giving rise to including \clearpage inside the group.

If you did not use the tocloft package, then you can follow the same procedure but use

\let\ps@plain\ps@empty

since each chapter first page is set with the plain page style!

Werner
  • 603,163
  • Thanks for the quick answer, that helped me alot. I also added \setcounter{page}{0} to the text to exclude this page from the total of pages. –  Nov 13 '13 at 08:34