# differences when using inline mode and \overline and \sqrt

Can anyone help me make this square root signs in the code below, be of the same size so that they all have the same height? This is the code:

\documentclass[]{book}

\begin{document}

$\overline{\sqrt{v_{x}^{2}}}$ and
$\overline{\sqrt{v_{y}^{2}}}$ and
$\overline{\sqrt{v_{h}^{2}}}$

\end{document}


Thanks

EDIT (13/08/2018):

\documentclass[a4paper]{book}

\usepackage[]{biblatex}

\usepackage{graphicx}
\usepackage{subfig} %for subfigures

\begin{document}

\begin{figure}%
\centering
\subfloat[SUB CAPTION TEXT]{{\includegraphics[width=.48\textwidth]{image1.pdf} }}%
~
\subfloat[SUB CAPTION TEXT]{{\includegraphics[width=.48\textwidth]{image2.pdf} }}%
\newline
\subfloat[SUB CAPTION TEXT]{{\includegraphics[width=.48\textwidth]{image3.pdf} }}%
~
\subfloat[SUB CAPTION TEXT]{{\includegraphics[width=.48\textwidth]{image4.pdf} }}%
\caption{$\overline{\sqrt{v_{\vphantom{h}\smash{y}}^{2}}}$}%
\label{fig:du}%
\end{figure}

\end{document}

• you could put a use {\strut x} and same for y and h so all three have the same height and depth. – David Carlisle Aug 11 '18 at 16:38
• \vphantom and \smash are fragile; you need \protect in front of them when in a caption. – egreg Aug 13 '18 at 16:44
• @egreg thanks, this was also pointed out by Bernard in another comment. – slew123 Aug 15 '18 at 14:33

Here are solutions, based on \smash and \vphantom:

\documentclass[]{book}

\begin{document}

$\overline{\sqrt{v_{x}^{2}}}$ and
$\overline{\sqrt{v_{\smash{y}}^{2}}}$ and
$\overline{\sqrt{v_{h}^{2}}}$\\

If you’re a perfectionist, you can also have the exponent 2 at the same height: \\

$\overline{\sqrt{v_{\vphantom{h}x}^{2}}}$ and
$\overline{\sqrt{v_{\vphantom{h}\smash{y}}^{2}}}$ and
$\overline{\sqrt{v_{h}^{2}}}$

\end{document}


• I don't see any effect with \smash{y} in your answer. Both lines look identitical, to me. – pzorba75 Aug 12 '18 at 4:14
• @pzorba75: \smash{y} suppresses the effect of the descender iny (the part below the baseline. The difference between bothlines comes from adding \vphantom{h}which makes the exponent $2$ be placed exactly at the same height in all roots of the second line, whereas in the first line, the first two exponents are slightly lower. Zooming at > 200 %, you can see it distinctly (the distance with the horizontal line of the square root is 0.9 pt in one case, 0.5pt in the other). – Bernard Aug 12 '18 at 8:45
• I received an error message: Incomplete \iffalse; all text was ignored after line 1334. This occurred when trying to use the syntax below in a caption for a figure: $\overline{\sqrt{v_{\vphantom{h}x}^{2}}}$ – slew123 Aug 12 '18 at 13:58

I would use \strut:

\documentclass{book}
\begin{document}
$\overline{\sqrt{\strut v_{x}^{2}}}$ and
$\overline{\sqrt{\strut v_{y}^{2}}}$ and
$\overline{\sqrt{\strut v_{h}^{2}}}$
\end{document}

• I get the error message: Incompatible list can't be unboxed. ...surements.\relax }}{50}{figure.caption.35}when trying to use that syntax inside a caption for a figure. – slew123 Aug 12 '18 at 14:03
• @slew123: Do you have the same error message if you move this code outside \caption? – Bernard Aug 12 '18 at 14:42
• I have no error, even in a \caption of a figure. – F. Pantigny Aug 12 '18 at 14:55
• @Bernard I'm using the symbol inside figures which are created using graphicx and subfig packages. Error occurs. No error when used outside a caption. – slew123 Aug 13 '18 at 15:32
• @slew123: Could you post a minimal example code reproducing the problem? – Bernard Aug 13 '18 at 15:42