# How to prevent superscripts from moving under \sqrt?

When I put an expression with superscripts under a \sqrt, the superscripts (here "vis") move down a bit. How can I prevent that, so that it looks consistent no matter whether it's under a root or not?

Source:

\documentclass{article}
\begin{document}
$(E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2$
$\sqrt{ (E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2}$
\end{document}

-

LaTeX knows eight math styles, four main ones and four secondary. They are called \displaystyle, \textstyle, \scriptstyle and \scriptscriptstyle. In general TeX chooses automatically the right style. In some constructions it uses the secondary style, frequently called the “cramped version”.

For instance, when typesetting a fraction when the current style is \displaystyle, TeX will choose \textstyle for the numerator and the cramped version for the denominator. Similarly, what's under a radical is typeset in the cramped version of the current style.

The “cramped” version is so called because exponents are set lower than in the uncramped style, which is exactly the problem you are seeing. This is automatic, so you need to override the style selection manually:

\documentclass{article}
\begin{document}
$(E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2$
$\sqrt{ (E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2}$
$\sqrt{\displaystyle (E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2}$
\end{document}


-
+1 Nice! But the question based on your statement This is automatic is: why? –  Sigur Jan 16 '14 at 22:30
@Sigur Because Knuth so decreed. –  egreg Jan 16 '14 at 22:40
oh, in this case, we must accept it. –  Sigur Jan 16 '14 at 22:47

Put the intermediate result in a box.

\documentclass{article}
\begin{document}
$(E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2$
$\sqrt{ (E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2}$
\newsavebox\tempbox
\sbox\tempbox{$\displaystyle(E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2$}
$\sqrt{\usebox\tempbox}$
\end{document}


-
Thanks! It also works without the box, what does the trick is the \displaystyle command: \sqrt{ \displaystyle (E^\mathrm{vis}_x)^2 + (E^\mathrm{vis}_y)^2}. –  jdm Jan 16 '14 at 21:38
@jdm Even better answer than mine. You should post your own result as an answer and accept that as the preferable one. –  Steven B. Segletes Jan 16 '14 at 21:41
I found that solution just a minute after writing the question, but didn't post it immediately because I was hoping that someone would explain how it works. Also its too late, egreg was too fast :-) and added an explanation. –  jdm Jan 16 '14 at 21:51