I've encountered a strange collision between RevTeX and AMSLaTeX. If I nest a split environment inside an align environment, it works as it should, but then the next time I use the RevTeX \tensor{} macro in the document, it repeats the last line of the split equation.

Here is a minimal "working" example:

\documentclass[12pt,prd,amsmath]{revtex4}
\begin{document}
Here is a split inside an align
\begin{align}
A &= B \\
\begin{split}
C &= D \\
&= E
\end{split}
\end{align}
And now we write a tensor $\tensor{T}$ which grabs the second line.
\end{document}

The problem shows up with split because, for strange reasons, amsmath.sty says \global\setbox\tw@ and doesn't use it if the ctagsplit option is selected, which is not good programming. However I remain with the opinion that \box2 in \tensor is simply wrong.
–
egregNov 28 '12 at 23:08

The key is \box 2. What is happening is \tensor is inserting whatever happens to be in that box. Presumably this is normally perfectly safe, but the same box is being used by align, which you can see with something like

I believe that \mathord{\box 2} is totally misplaced. The macro \tensor relies ultimately on \@@ontopof which sets (locally) \box\tw@, but apparently does nothing with it; the setting happens in a group, so that box construction disappears anyway. \tensor is not the only macro using it.
–
egregNov 28 '12 at 22:31

The problem is that the assigment for box 2 is done locally inside a group (BTW, even numbered registers 0, 2, 4, 6, and 8 are for local assignments, odd numbered 1, 3, 5, 7, and 9 for global assignments). Thus after \@ontopof has done its work, the setting of box 2 is lost and the previous contents of box 2 is used in \tensor.

I assume that the idea was that the composite symbol keeps the original height and depth of the base symbol. This avoids ruining the line spacing by symbols with large heights, but at the risk of clashes.

The following example implements this idea

\m@th is added in the box settings to reset \mathsurround to avoid unwanted space additions, if \mathsurround is not zero.

The complexity of the box structure is simplified.

Fix for the case the base symbol's width is between 0.9 and 1 of the width of the top symbol.

There are other macros besides \tensor that use \@ontopof with \box2.

Guessed explanation for using 90% of the width of the top symbol:
Depending on the width of the symbols the smaller symbol is horizontally centered in a box with the width of the wider symbol. Whereas the full width of the base symbol is taken, only the real width of the top symbol is taken. The full width consists of the real glyph width and the left and right side bearings. The code assumes 5% for each side and estimates the glyph width to 90% of the character box width.