I am using the revtex4 package and wanted to change the section numbers to arabic for all levels. Furthermore, I wanted the sections to be displayed as 1.2. (as opposed to 2. only).
I only use sections and subsections, so I did the following:
\def\thesection{\arabic{section}}
\def\thesubsection{\thesection.\arabic{subsection}}
Now the sections and subsections are displayed how I want them. However, referencing subsections is now broken. It displays like this (edited example):
\documentclass[twocolumn,pre,floats,aps,amsmath,amssymb,a4,floatfix]{revtex4}
\usepackage{acronym}
\usepackage[english]{babel}
\setcounter{secnumdepth}{3}
\pagenumbering{arabic}
\def\thesection {\arabic{section}}
\def\thesubsection {\thesection.\arabic{subsection}}
\begin{document}
\section{First Section}
\subsection{A Subsection}
\label{sub:example}
And then some text.
\section{Second Section}
Let's ref Section \ref{sub:example}.
\end{document}
… instead of 1.1
.
I see two resolutions, but don't know how to go about any of them:
-
Change the display numbers of sections in a smarter way, OR
-
Change what \ref displays (so that it displays only the subsection
when subsections are referenced.
How can I achieve any of these, or is there another way?
Best Answer
A
\label
to some counter likesubsection
is normally constructed as\p@subsection\thesubsection
. In most cases the "prefix" command\p@...
doesn't typeset anything and thus the result is the same what is produced by\the...
. Such "prefix" commands are only used by the standard classes to construct references like 1.a in enumerations when the items there are labeled1
and the subitema
.The
revtex4.cls
however is using the\p@...
commands also for heading counters:So if you change
\thesubsection
as you did you end up with the following:In other words you need to also change all the corresponding
\p@...
commands to expand to nothing. I the document preamble place: