3

How can I remove the page number of a specific section in the TOC: enter image description here

the mwe I'm using is:

    \documentclass[12pt,a4paper]{revtex4-1}
\usepackage{graphicx}% Include figure files
\usepackage{bm}% bold math
\usepackage[usenames]{color}
\usepackage[all]{xy}
\usepackage{amsmath}
\usepackage{fixmath}
\usepackage{natbib}
\usepackage{placeins}
\usepackage{verbatim}
\usepackage[top=0.59in,bottom=0.59in,left=0.59in,right=0.59in]{geometry}
%% packges not from aps
\usepackage{amssymb}
\usepackage{float}
\usepackage[nice]{nicefrac}
\usepackage{chemmacros}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{multirow}
\hypersetup{
  colorlinks   = true, %Colours links instead of ugly boxes
  urlcolor     = red, %Colour for external hyperlinks
  linkcolor    = black, %Colour of internal links
  citecolor   = black %Colour of citations
}
\setlength{\parindent}{0pt}
\setlength{\abovecaptionskip}{0pt plus 0pt minus 0pt}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\alph{subsection}}
\def\bibsection{\section{\refname}} 

\begin{document}
\tableofcontents
\setcounter{page}{1}
\newpage
\section{section 1}
bla bla bla
\newpage
\section{section 2}
bla bla bla
\newpage
\section{section 3}
bla bla bla
\newpage
\section{section 4}
bla bla bla
\end{document}
  • 1
    This would look weird, actually. Since you're using revtex this is not easy, as far as I know, otherwise with tocloft package it would be very easy. – user31729 Mar 20 '17 at 17:11
  • @ChristianHupfer, indeed. – jarhead Mar 20 '17 at 17:13
  • @jarhead Just curious: can you explain why you need to remove the number? – user36296 Mar 20 '17 at 17:27
  • @samcarter, this is the way I need to edit the document – jarhead Mar 20 '17 at 17:28
3

You can use the following switches to change what is displayed in the ToC:

  • \droptocpage: Remove page references in ToC from this point onward;
  • \incltocpage: Restore page references in ToC from this point onward.

enter image description here

\documentclass{revtex4-1}

\usepackage{hyperref}

\renewcommand{\thesection}{\arabic{section}}% Just for this example

\AtBeginDocument{\let\oldcontentsline\contentsline}
\newcommand{\notoccontentsline}[4]{\oldcontentsline{#1}{#2}{}{#4}}
\newcommand{\droptocpage}{\addtocontents{toc}{\let\protect\contentsline\protect\notoccontentsline}}
\newcommand{\incltocpage}{\addtocontents{toc}{\let\protect\contentsline\protect\oldcontentsline}}

\begin{document}

\tableofcontents

\clearpage
\section{First section}
bla bla bla

\clearpage
\section{Second section}
bla bla bla

\clearpage
\droptocpage
\section{Third section}
bla bla bla

\clearpage
\incltocpage
\section{Fourth section}
bla bla bla

\end{document}

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.