3

I'm having a problem with REVTeX adding unnumbered sections to my TOC. Here's a small example:

\documentclass[]{revtex4-1}
\usepackage{lipsum}

\begin{document}

\tableofcontents
\newpage

\section{Numbered section}
\lipsum
\section*{Unnumbered section}
\lipsum

\end{document}

Outputs the following:

Contents page: Contents page Body: Sections

Is this a bug? Is there a problem with my installation?

The unnumbered sections are not there if I use a different document class (e.g. article).

Jack Yates
  • 133
  • 2

1 Answers1

3

This is a design choice of the class; you can change this by redefining (or patching \@ssect@ltx).

With the redefinition:

\documentclass[]{revtex4-1}

\makeatletter
\def\@ssect@ltx#1#2#3#4#5#6[#7]#8{%
  \def\H@svsec{\phantomsection}%
  \@tempskipa #5\relax
  \@ifdim{\@tempskipa>\z@}{%
    \begingroup
      \interlinepenalty \@M
      #6{%
       \@ifundefined{@hangfroms@#1}{\@hang@froms}{\csname @hangfroms@#1\endcsname}%
       {\hskip#3\relax\H@svsec}{#8}%
      }%
      \@@par
    \endgroup
    \@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
    %\addcontentsline{toc}{#1}{\protect\numberline{}#8}%
  }{%
    \def\@svsechd{%
      #6{%
       \@ifundefined{@runin@tos@#1}{\@runin@tos}{\csname @runin@tos@#1\endcsname}%
       {\hskip#3\relax\H@svsec}{#8}%
      }%
      \@ifundefined{#1smark}{\@gobble}{\csname #1smark\endcsname}{#7}%
      \addcontentsline{toc}{#1}{\protect\numberline{}#8}%
    }%
  }%
  \@xsect{#5}%
}%
\makeatother

\begin{document}

\tableofcontents

\section{Numbered section}
\section*{Unnumbered section}

\end{document}

enter image description here

With the patch:

\documentclass[]{revtex4-1}
\usepackage{xpatch}

\makeatletter
\patchcmd{\@ssect@ltx}
    {\addcontentsline{toc}{#1}{\protect\numberline{}#8}}
    {}
    {}
    {}
\makeatother

\begin{document}

\tableofcontents

\section{Numbered section}
\section*{Unnumbered section}

\end{document}
Gonzalo Medina
  • 505,128