# How to make \ref display only subsection

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:

1. Change the display numbers of sections in a smarter way, OR

2. 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?

-

A \label to some counter like subsection 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 labeled 1 and the subitem a.

The revtex4.cls however is using the \p@...commands also for heading counters:

\def\thesection       {\Roman{section}}
\def\p@section        {}
\def\thesubsection    {\Alph{subsection}}
\def\p@subsection     {\thesection\,}
\def\thesubsubsection {\arabic{subsubsection}}
\def\p@subsubsection  {\thesection\,\thesubsection\,}


So if you change \thesubsection as you did you end up with the following:

\thesection\,\thesection.\arabic{subsection}


In other words you need to also change all the corresponding \p@...commands to expand to nothing. I the document preamble place:

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

-
thank you for your extended reply. I did try what you propose, but that didn't help. I extended the example above to make the issue more clear (the "see" in the previous example was due to Dropbox not syncing properly, should have been in the TeX). –  Shade Jun 28 '12 at 8:24
you are missing some basic knowledge here, sorry, could have added that part: Commands that contain @ in their name can only appear in package or class files. Outside, e.g., in the preamble you need to surround them with \makeatletter command defs \makeatother. So what you defined above is really the command \p that has to be followed by the string @sectionwhich is not the same thing. I updated my answer to include this. –  Frank Mittelbach Jun 28 '12 at 8:37
True, I am not very knowledgeable with Latex, but I guess that's what you get by only learning by example.. Thank you very much for your help! –  Shade Jun 28 '12 at 8:57