Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

up vote 17 down vote accepted

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

share|improve this answer
2  
+1 Nice! But the question based on your statement This is automatic is: why? –  Sigur Jan 16 at 22:30
4  
@Sigur Because Knuth so decreed. –  egreg Jan 16 at 22:40
    
oh, in this case, we must accept it. –  Sigur Jan 16 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}

enter image description here

share|improve this answer
    
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 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 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 at 21:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.