Math Mode – How to Prevent Superscripts from Moving Under \sqrt in LaTeX

math-modesuperscripts

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?

enter image description here

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}

Best Answer

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}

enter image description here