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.

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

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 Apr 9 '13 at 16:06
  • Welcome to TeX.SX. Apr 9 '13 at 16:11
  • 2
    @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. Apr 9 '13 at 16:15
  • 2
    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
  • 2
    @barbarabeeton in that case you could do \vphantom{(} and save a couple of keystrokes. Apr 9 '13 at 16:27

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

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


  • 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.

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.