1

I would like to display the page numbers in the table of contents of the sections only in revTex. Please here is a minimal working environment:

\documentclass[aps]{revtex4-1}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc} 

\begin{document}

\section{First section}
\subsection{First subsection of first section}
\subsection{Second subsection of first section}

\section{Second section}
\subsection{First subsection of second section}
\subsection{Second subsection of second section}

\tableofcontents

\end{document} 

I.e. only the page number for the first and second sections should be displayed. Any help is highly appreciated.

Thanks,

hartmut

0
2

The revtex4-1 class uses the same format for every line the the toc, just changing the indentation. You could reduce the clutter using etools, but the net effect will be the same.

\documentclass[aps]{revtex4-1}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc} 

\makeatletter
\def\l@@sections#1#2#3#4{%
 \begingroup
  \everypar{}%
  \set@tocdim@pagenum\@tempboxa{#4}%
  \def\testA{subsection}\def\testB{#2}\ifx\testA\testB \set@tocdim@pagenum\@tempboxa{}\fi% one line patch
  \global\@tempdima\csname tocdim@#2\endcsname
  \leftskip\csname tocleft@#2\endcsname\relax
  \dimen@\csname tocleft@#1\endcsname\relax
  \parindent-\leftskip\advance\parindent\dimen@
  \rightskip\tocleft@pagenum plus 1fil\relax
  \skip@\parfillskip\parfillskip\z@
  \let\numberline\numberline@@sections
  \@nameuse{l@f@#2}%
  \ignorespaces#3\unskip\nobreak\hskip\skip@
  \hb@xt@\rightskip{\hfil\unhbox\@tempboxa}\hskip-\rightskip\hskip\z@skip
  \expandafter\par
  \expandafter\aftergroup\csname tocdim@#2%
  \expandafter\endcsname
  \expandafter\endgroup
              \the\@tempdima\relax
}%
\makeatother

\begin{document}

\section{First section}
\subsection{First subsection of first section}
\subsection{Second subsection of first section}

\section{Second section}
\subsection{First subsection of second section}
\subsection{Second subsection of second section}

\tableofcontents

\end{document} 

demo

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.