# Overset placement is uneven

I'm using this code to show that one element of the equation is greater than zero and the second element is less than zero.

\begin{align}
\overset{+}{\pi_{i}} + \overset{-}{w_{g}(S)} > 0
\end{align}


But the alignment of the plus and minus signs are uneven. The minus sign is quite a bit higher than the plus sign. I appreciate help getting the two at the same vertical placement.

• @Mico right. \overset{+}{\vphantom{S}\pi_{i}} + \overset{-}{w_{g}(S)} > 0 – Gonzalo Medina Apr 9 '13 at 16:06
• – Claudio Fiandrino Apr 9 '13 at 16:11
• @GonzaloMedina -- not quite ... for the alignment to be perfect, the first element is best coded as \overset{+}{\vphantom{(S)}\pi_{i}} including the parentheses around the S. the difference isn't great, but if you set the two of them closely side by side, with no intervening plus, it's visible. – barbara beeton Apr 9 '13 at 16:15
• I suppose the first expression could be simplified further to \overset{+}{\vphantom{(}\pi_{i}} or -- prettier still -- \overset{+}{\mathstrut\pi_{i}} (because we have \def\mathstrut{\vphantom(}). See also tex.stackexchange.com/a/41192/5001. – Mico Apr 9 '13 at 16:26
• @barbarabeeton in that case you could do \vphantom{(} and save a couple of keystrokes. – David Carlisle Apr 9 '13 at 16:27

the most compact approach to this is to add \mathstrut:

\begin{align}
\overset{+}{\mathstrut\pi_{i}} + \overset{-}{w_{g}(S)} > 0
\end{align}


explanation:

• the \overset adjustment is based on the tallest element in the expressions, namely the parentheses around the S.

• \mathstrut is defined as {\vphantom(}.

a lot of comments contributed to this. mico's the one who finally came up with \mathstrut.