如何隐藏内容的页码?

如何隐藏内容的页码?

我使用\tableofcontents命令,然后\addcontentsline将“简介”添加到内容中。简介设置为第 1 页,但我的目录也显示了第 1 页。然后我有第 1 页和第 2 页(目录 - 两页到目录),第 1 页之后再次显示简介。我使用包hyperref,当我单击目录中的“简介”时,它会将我带到目录而不是简介...其他部分都正常。

1)我想隐藏内容的页码(第二页我可以这样做,但第一页不可以);

2)我希望当我点击目录中的“简介”时,会转到“简介”页面


我的代码:

\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

您必须\pagestyle{empty}在前言持续期间发出命令,然后恢复默认值\pagestyle{plain}

我建议也说明不同的页码方案,以确保hyperref满意并建立正确的链接。我还建议titles选择tocloft

在以下示例中,我删除了几乎所有不必要的包(此外fontenc,、和对于展示示例来说并不是真正需要的);将删除的包重新添加到文档中。由于您正在使用,因此您将没有明确的环境,但使用的方法将以相同的方式工作,而无需任何命令。inputencbabelgeometrynatbibthebibliographytocbibind\addcontentsline

\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}

在此处输入图片描述

相关内容