8

I'm getting a weird result using the code that follows. The square root symbols don't match. In particular, the second square root symbol has a far greater depth than the first does. (The second symbol's height is also greater, but it's not as prominent as the depth issue.)

enter image description here

\documentclass{article}
\begin{document}
   \begin{equation}
      \frac{1}{\sqrt{2 \pi \sigma_x^2}} 
      \frac{1}{\sqrt{2 \pi \sigma_y^2}}     
   \end{equation}
\end{document}
2
  • 1
    Welcome to TeX SE. Could you expand your code to a minimal working example? Also what do you mean by they don't match. Since y has a descender. the square root should go a bit lower in the second. Commented May 23 at 15:45
  • You culd just add a \strut to both expressions (inside the square roots) Commented May 23 at 16:44

2 Answers 2

13

Getting square roots signs right is a kind of black art.

For the particular case, I'd ignore the depth of the radicands and add a phantom after the second square root to get the vertical spacing right.

The rationale is that the subscripts are far enough from the radical so that “covering” them isn't necessary.

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}

\begin{document}

\lipsum[1][1-4]
\begin{equation}
\frac{1}{\sqrt{\smash[b]{2 \pi \sigma_{x}^{2}}}}
\frac{1}{\sqrt{\smash[b]{2 \pi \sigma_{y}^{2}}}\vphantom{\sigma_{y}^{2}}}
\end{equation}
\lipsum[2][1-3]

\end{document}

enter image description here

Maybe you can consider that in denominators usually TeX employs cramped style:

\documentclass{article}
\usepackage{amsmath,mathtools}

\usepackage{lipsum}

\begin{document}

\lipsum[1][1-4]
\begin{equation}
\frac{1}{\sqrt{\smash[b]{\cramped{2 \pi \sigma_{x}^{2}}}}}
\frac{1}{\sqrt{\smash[b]{\cramped{2 \pi \sigma_{y}^{2}}}}\vphantom{\cramped{\sigma_{y}^{2}}}}
\end{equation}
\lipsum[2][1-3]

\end{document}

enter image description here

Leave such optimization for the final revision. Depending on the actual formulas, the \vphantom might not be necessary.

0
5

The problem is that the letter y has some depth, whereas x has none. I see three solutions to solve this.

  1. You could use \mathstrut for x, which will insert the height of an imaginary ( (open parenthesis). Note that although the radix sign will be equally large, the exponent 2 for x will be higher than that for y since ( has a bigger height than y. This is probably the standard solution.
  2. You could use \smash{...} for y, which will eliminate the height and depth of y. This might look more symmetrical, but to be pedantic, the lowest point of y will be a bit lower than that of the radix sign. Specifying the optional argument b for \smash will only eliminate the depth of y, retaining it's height. I prefer this solution, as it won't create excessive white space.
  3. You could add \vphantom{...} for x in order to fake the depth of the letter y. This is probably the most correct solution, although I find it a bit ugly.
\documentclass{article}
\usepackage{amsmath}

\begin{document}

\verb|\mathstrut|:
\begin{equation}
    \frac{1}{\sqrt{2 \pi \sigma_{\mathstrut x}^2}} \frac{1}{\sqrt{2 \pi \sigma_y^2}}
\end{equation}

\verb|\smash{...}|:
\begin{equation}
    \frac{1}{\sqrt{2 \pi \sigma_x^2}} \frac{1}{\sqrt{2 \pi \sigma_{\smash[b]{y}}^2}}
\end{equation}

\verb|\vphantom{...}|:
\begin{equation}
    \frac{1}{\sqrt{2 \pi \sigma_{\vphantom{y} x}^2}} \frac{1}{\sqrt{2 \pi \sigma_y^2}}
\end{equation}

\end{document}

enter image description here

2
  • 1
    Possibly better \smash[b]{y}. In any case, \smash y is wrong syntax; the fact that it gives the desired output doesn't make it right.
    – egreg
    Commented May 23 at 16:23
  • @egreg You're right. I'll fix this. For others: note that the optional argument is only present with the amsmath package.
    – Gargantuar
    Commented May 23 at 16:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .