# Section reference shows section then subsection number

I am labeling a subsection with simply \label{labelname}, and referring to it later in my document with \ref{labelname}. However, at that point it doesn't print just the subsection number, e.g. 2.1, but it prints the section number followed by the subsection number, like 2 2.1. Can it be made to show the desired output?

Minimum example (using revtex4 class):

\documentclass[pre,12pt]{revtex4}
\renewcommand \thesection{\arabic{section}}
\renewcommand \thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand \thesubsubsection{\arabic{section}.\arabic{subsection}
\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\label{subsection1}
Some text.

\section{Section 2}
Previously seen in \ref{subsection1}
\end{document}

-
Probably you have some redefinition on your preamble. Post your minimal code here. –  Sigur Mar 27 '13 at 1:07
It's perhaps worth noting that I'm using the revtex4 class. –  dplanet Mar 27 '13 at 1:11
Here it prints IA without dot. Try to delete aux files and log files. –  Sigur Mar 27 '13 at 1:15
By default, the representation for the subsection counter in cross-references will be \thesection\, \Alph{subsection}. Do you want something different? –  Gonzalo Medina Mar 27 '13 at 1:20
There's a good reason for showing both the section as well as the subsection number when generating a cross-reference. Suppose you have subsections "numbered", say, A in sections II, III, and IV of your document. You'd be risking confusing your readers greatly if you just create a cross-reference to "subsection A" somewhere in the paper: is it supposed to be subsection A in section II, III, or IV? With enough time and energy, some readers will manage to figure out which of the three subsections is meant. All other readers will greatly appreciate call-outs of the form II.A or IV.A. –  Mico Mar 27 '13 at 2:26

The file revtex4.cls contains the lines

\def\thesubsection{\Alph{subsection}}
\def\p@subsection{\thesection\,}


so the representation for a cross-references to a subsection will be typeset as the upper-case alphabetic representation for the subsection counter prepended by the counter for sections and a thin space:

\documentclass[pre,12pt]{revtex4}

\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\label{subsection1}
Some text.
\section{Section 2}
Previously seen in~\ref{subsection1}
\end{document}


Since you have redefined \thesubsection to explicitly include the section counter, you'll get this counter duplicated. To prevent this, you can redefine \p@subsection; for example to suppress the prefix and keep just the representation for the subsection counter you could say:

\makeatletter
\def\p@subsection{}
\makeatother


A complete example:

\documentclass[pre,12pt]{revtex4}
\renewcommand\thesection{\arabic{section}}
\renewcommand\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}}

\makeatletter
\def\p@subsection{}
\makeatother

\begin{document}
\section{Section 1}
\subsection{Subsection 1}
\label{subsection1}
Some text.

\section{Section 2}
Previously seen in \ref{subsection1}
\end{document}


A similar redefinition of \p@subsubsection will have to be done, since the class does

\def\p@subsubsection{\thesection\,\thesubsection\,}

-
Strange! Reading the question I understand that he/she said that the reference number is 22.1 (like 2 2.1). –  Sigur Mar 27 '13 at 1:51
Hi, my minimum example stripped out code that I use to remove this ambiguity, i.e. by setting it to basically the default article class numbering (see updated preamble). –  dplanet Mar 27 '13 at 1:54
@dplanet same idea: redefine \p@subsection; see my updated answer. –  Gonzalo Medina Mar 27 '13 at 1:57
@Sigur yes, in fact that was what he/she was getting due to the redefinition of \thesubsection as can be seen from the edit to the question; my initial suggestion (redefining p@subsection) still applies. –  Gonzalo Medina Mar 27 '13 at 2:01