Generalno page number in table of contents

LaTeX specific issues not fitting into one of the other forums of this category.
Dott_JJ
Posts: 4
Joined: Sat Dec 03, 2011 5:44 pm

Re: no page number in table of contents

Post by Dott_JJ »

Hi Stefan,

thank you very much for your answer! Unfortunately I gave you a misleading explanation of my problem: I was referring to the bottompage numbering of the TOC! Usually in the standard text I solve the problem with the

\pagestyle{empty}

syntax but in the case of TOC it doesn't work. I then tried with the command line you suggested

\addtocontents{toc}{\protect\thispagestyle{empty}}

and it works indeed but only for the bottompage numbering of the first two pages (of four) of the TOC. I would like, if possible, to remove the bottompage numbering for all the four pages of the TOC.

Sorry for the misunderstanding,

Giacomo

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

no page number in table of contents

Post by Stefan Kottwitz »

Hi Giacomo,

so use both:

Code: Select all

\pagestyle{empty}
\addtocontents{toc}{\protect\thispagestyle{empty}}
\tableofcontents
\pagestyle cares for all pages except the first one, the first one has usually plain page style, as chapter starting pages, \thispagestyle cares for this first page.

Stefan
LaTeX.org admin
Dott_JJ
Posts: 4
Joined: Sat Dec 03, 2011 5:44 pm

no page number in table of contents

Post by Dott_JJ »

Hi Stefan,

I tried the code you suggested me but it did not work... I'm writing here my entire code, I'm likely to be doing something wrong without realizing:

Code: Select all


\documentclass[12pt,openright]{book}
\usepackage{times}
\usepackage[a4paper,margin=1in,twoside,nohead]{geometry}
\geometry{lmargin=1.5in}
%(...) Other packages here

\onehalfspacing %Serve per interlinea 1.5

\begin{document}
\pagestyle{empty}

\makeatletter
\renewcommand\part{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}
\makeatother

\pagestyle{empty} \addtocontents{toc}{\protect\thispagestyle{empty}}
%Does not work!

\tableofcontents

\pagestyle{fancy}
\renewcommand\headrulewidth{0pt}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhead{} \fancyfoot{} \fancyfoot[CO,CE]{\bfseries\thepage}
\frontmatter

\include{Intro}

\mainmatter

%...etc

Thank you very much,

Giacomo
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

no page number in table of contents

Post by Stefan Kottwitz »

In that code part \pagestyle{fancy} affects the last page of the table of contents. Begin a new page before you change the pagestyle, such as

Code: Select all

\tableofcontents
\cleardoublepage
\pagestyle{fancy}
If that doesn't work for you, post a compilable example which produces the undesired numbering, as the code above cannot be tested, when I make it testable it works fine after \cleardoublepage or \clearpage between \tableofcontents and \pagestyle{fancy}.

Stefan
LaTeX.org admin
Dott_JJ
Posts: 4
Joined: Sat Dec 03, 2011 5:44 pm

Re: no page number in table of contents

Post by Dott_JJ »

Hi Stefan!

With the addition of \cleardoublepage everything worked perfectly. Thank you very much for your suggestions! Best regards,

Giacomo
Post Reply