# Apparent Instability in REVTeX4 After Adding xpatch Package

This is a follow-up question to How can Acrobat features be controlled from within LaTeX?

It seems that xpatch package makes REVTeX unstable and even appears to turn off some of its features. Thus, instead of making an Acrobat 5 document it makes Acrobat 9 if both are installed. More worrisome, however, is the sudden change of behavior for unknown reasons. I was working with a document and all went just fine but all of a sudden my WinEdt refused to compile it. Numerous errors showed cross-referencing problems. It turned out the culprit is \affiliation{}. As soon as I removed it, the problem disappeared. Unfortunately, I cannot demonstrate it in a MWE because it doesn't show up there. What shows up in a MWE is another problem---\section{} does not accept \textbf{}:

\documentclass[onecolumn,twoside]{revtex4}

\usepackage{xpatch}% http://ctan.org/pkg/xpatch
\makeatletter
\xpatchcmd{\@ssect@ltx}{\@xsect}{\edef\@currentlabelname{#8}\@xsect}{}{}%     Patch \<section>*
\xpatchcmd{\@sect@ltx}{\@xsect}{\edef\@currentlabelname{#8}\@xsect}{}{}% Patch \<section>
\makeatother
\usepackage{hyperref}% http://ctan.org/pkg/hyperref

\hypersetup{pdfstartview=FitH,pdfpagemode=UseNone}

\begin{document}

\title{Title}
\author{Author}
\affiliation{Affiliation}

\maketitle

%\section*{FirstSection--$E \times H$ vs.$\ \textbf{E} \times \textbf{H}$}
\section*{FirstSection}

\label{sec:marker1}
In \nameref{sec:marker2} it is stated that \ldots

\section*{SecondSection} \label{sec:marker2}
You can also see in \nameref{sec:marker1} that \ldots
\end{document}


As you can see, the above example works as long as \section*{FirstSection--$E \times H$ vs.$\ \textbf{E} \times \textbf{H}$}, containing \textbf{} characters, is remmed out. If you un-rem it and instead rem out \section*{FirstSection} the compilation crashes.

Do you think I should live with it and have the affiliation follow the author in \author{} and instead of \textbf{Something} should use \bf Something \rm instead or there are radical solutions of this instability, if at all?

-
The patching should use \protected@edef rather than just \edef. –  Joseph Wright Feb 18 '12 at 7:38
That indeed takes care of the \textbf{} problem but doesn't solve the \affiliation{} one. –  ganzewoort Feb 18 '12 at 7:53
It appears the patch doesn't like long abstracts with separate paragraphs. It would accept such, as long as \affiliation{} is remmed out. –  ganzewoort Feb 18 '12 at 8:16
The \affiliation macro is not 'long'. That has nothing to do with xpatch: you see the same without loading it. Probably the author of REVTeX does not expect affiliations to be large blocks of text. –  Joseph Wright Feb 18 '12 at 8:25
As noted in the answers and comments in the question that you reference, you should not be using revtex4, but rather revtex4-1. This may seem like an incremental difference, but there's something like a 10 year gap between the two! –  qubyte Feb 18 '12 at 9:03

The \affiliation macro is not 'long'. That has nothing to do with xpatch: you see the same without loading it. Probably the author of REVTeX does not expect affiliations to be large blocks of text.