5

I have a revtex4 document and I'd like to change how the labels for the subsections appear:

\section{Foo}
\subsection{Bar}

Currently compiles to something like:

I. Foo
A. Bar

But I'd like it to appear as:

I. Foo
I.A Bar

I can do this without too much trouble by adding a new command:
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}

But this messses up how references to sections/subsections appear in the text. If I label them as sec:Foo and subsec:Bar then if I write:

lots of stuff happens in section \ref{sec:Foo}
and specifically this interesting thing appears in \ref{subsec:Bar}  

then that is compiled to:

lots of stuff happens in section I and specifically this interesting thing happens appears in I I.A

But I'd like it to appear as:

lots of stuff happens in section I and specifically this interesting thing happens appears in I.A

I feel like I'm trying to have my cake and eat it too, but it isn't working out. I feel like there is something deeper that I'm missing about how the section numbering/labelling commands work that I'm missing. Any suggestions?

  • revtex4-1 is for submissions to some journals; if you change the layout, the journal's copy editors won't be happy and this may even cause rejection of the paper. – egreg Jan 15 '15 at 22:37
  • Indeed! But for whatever reason my advisor has strong feelings about the way things look in the draft process, so I was just going to make a parallel branch with the formatting that they like while we're working on it. – ACN Jan 15 '15 at 23:39
6

The revtex4 class adds a prefix to the cross-references to subsections since it uses

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

so, in addition to

\def\thesubsection{\thesection.\Alph{subsection}}

you will also need

\def\p@subsection{}

to suppress the prefix:

\documentclass{revtex4}

\makeatletter
\def\thesubsection{\thesection.\Alph{subsection}}
\def\p@subsection{}
\makeatother

\begin{document}

\section{Test section}
\label{sec:testsec}
\subsection{Test subsection}
\label{sec:testsubsec}

Cross reference to the section~\ref{sec:testsec} and to the subsection~\ref{sec:testsubsec}.

\end{document}

enter image description here

Since the class does something similar for other sectional units, as you can see for subsections:

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

then you might also need to add something like

\def\thesubsubsection{\thesubsection.\arabic{subsubsection}}
\def\p@subsubsection{}

(and something similar for lower units) if you want to keep the same style for lower sectional units.

\documentclass{revtex4}

\makeatletter
\def\thesubsection{\thesection.\Alph{subsection}}
\def\p@subsection{}
\def\thesubsubsection{\thesubsection.\arabic{subsubsection}}
\def\p@subsubsection{}
\makeatother

\begin{document}

\section{Test section}
\label{sec:testsec}
\subsection{Test subsection}
\label{sec:testsubsec}
\subsubsection{Test subsection}
\label{sec:testsubsubsec}

Cross reference to the section~\ref{sec:testsec}, to the subsection~\ref{sec:testsubsec} and to the subsubsection~\ref{sec:testsubsubsec}.

\end{document}

enter image description here

  • That's exactly what I was looking for. The key part I was missing was revtex pre-fix. Thank you! – ACN Jan 15 '15 at 20:45

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.