2

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}
3
  • 1
    you could put a use {\strut x} and same for y and h so all three have the same height and depth. Commented Aug 11, 2018 at 16:38
  • \vphantom and \smash are fragile; you need \protect in front of them when in a caption.
    – egreg
    Commented Aug 13, 2018 at 16:44
  • @egreg thanks, this was also pointed out by Bernard in another comment.
    – slew123
    Commented Aug 15, 2018 at 14:33

2 Answers 2

1

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} 

enter image description here

3
  • I don't see any effect with \smash{y} in your answer. Both lines look identitical, to me.
    – pzorba75
    Commented Aug 12, 2018 at 4:14
  • 1
    @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
    Commented Aug 12, 2018 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
    Commented Aug 12, 2018 at 13:58
0

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}
8
  • 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
    Commented Aug 12, 2018 at 14:03
  • @slew123: Do you have the same error message if you move this code outside \caption?
    – Bernard
    Commented Aug 12, 2018 at 14:42
  • I have no error, even in a \caption of a figure. Commented Aug 12, 2018 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
    Commented Aug 13, 2018 at 15:32
  • @slew123: Could you post a minimal example code reproducing the problem?
    – Bernard
    Commented Aug 13, 2018 at 15:42

You must log in to answer this question.

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