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).

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}
  • Perfect, thanks. I did look at the REVTeX guides and other such documents, but couldn't find any mention of unnumbered sections in the TOC. Thanks for your help. – Jack Yates Apr 14 '14 at 15:56

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.