3

I used the \tableofcontents command and then \addcontentsline to add "Introduction" to the contents. The introduction is set as page 1, but my ToC shows a page1 to itself, too. Then I have page 1 and 2 (ToC - two pages to ToC) and after page 1 again for the introduction. I use the package hyperref and when I click on "Introduction" in ToC, it takes me to the ToC instead Introduction... the others sections are ok.

1) I wanna hide the page number of contents (the second page I could do that, but the first one not);

2) I want when I click on Introduction in ToC, this takes me to the Introduction page


My code:

\documentclass[pdftex,12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english, portuguese]{babel}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage[numbers]{natbib}
\usepackage{geometry}
\geometry{bmargin=2cm,tmargin=3cm,lmargin=3cm,rmargin=2cm}

\usepackage{setspace}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{braket}
\usepackage{natbib}

\usepackage{caption}
\usepackage{subcaption}

\renewcommand{\rmdefault}{phv} % Arial, as duas linhas juntas
\renewcommand{\sfdefault}{phv}

\usepackage{standalone}

\usepackage{tocloft}
%\renewcommand\tocloftpagestyle{empty} %I tried this but didn't work :(
\addto\captionsportuguese{\renewcommand*\contentsname{Sumário}}

\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    urlcolor=red,
    citecolor=blue,
    pdftitle={Teoria de cordas bosônica},
    bookmarks=true,
}

\begin{document}

\include{pages}
...(more includes here) If it helps, two of the "\addcontentsline{chapter}{X}" are in these included files: introduction and conclusion.

\tableofcontents
(I put "\pagestyle{empty}" right here and I solve the problem for the second page of the ToC)
\newpage

\include{introduction}

\chapters and chapter here...

\addcontentsline{toc}{chapter}{Bibliografia}
\begin{thebibliography}{7}

some \bibitem

\end{thebibliography}
\end{document}
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible) and as short as possible. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – LaRiFaRi Aug 12 '15 at 8:37
1

You have to issue \pagestyle{empty} for the duration of the front matter and then restore the default \pagestyle{plain}.

I recommend stating also a different page numbering scheme for keeping hyperref happy and make the right links. Also I recommend the titles option to tocloft.

In the following example I removed almost all the unnecessary packages (also fontenc, inputenc, babel and geometry aren't really needed to show the example); add the removed ones back into your document. Since you're using natbib you won't have an explicit thebibliography environment, but the method with tocbibind will work the same without any \addcontentsline command.

\documentclass[12pt,a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, portuguese]{babel}

\usepackage{geometry}
\geometry{bmargin=2cm,tmargin=3cm,lmargin=3cm,rmargin=2cm}

\usepackage[titles]{tocloft} % <--- titles option
\usepackage[nottoc]{tocbibind} % <--- add the bibliography in the toc
\usepackage{etoolbox}

\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    urlcolor=red,
    citecolor=blue,
    pdftitle={Teoria de cordas bosônica},
%    bookmarks=true, % that's already the default
}

\addto\captionsportuguese{\renewcommand*\contentsname{Sumário}}

%% let's fix \tableofcontents so it uses \thispagestyle{empty}
\makeatletter
\patchcmd{\tableofcontents}{\@starttoc}{\thispagestyle{empty}\@starttoc}{}{}
\makeatother

\begin{document}

\pagenumbering{Alph} % for keeping hyperref happy
\pagestyle{empty}

\tableofcontents

\cleardoublepage

\pagenumbering{arabic}
\pagestyle{plain}

\chapter{Introduction}

Whatever

\newpage

Again

\chapter{Something more}

Whatever

\newpage

Again

\begin{thebibliography}{7}

\bibitem{x} Y

\end{thebibliography}

\end{document}

enter image description here

  • Thank you very much!!! It helped me a lot. I got you said but I don't understand why my programm doesn't accept "\pagenumbering{Alph}". When I compile it says there are some errors and go to parts of document that doesn't affect it, like equations and sections. I'll try to fix this but not now, I need to present my work next week. – Enrique René Aug 13 '15 at 17:30
  • @EnriqueRené I'm sorry to learn this; try making a minimal example producing the error and ask a new question. – egreg Aug 13 '15 at 17:33

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.