[Tex/LaTex] \underbrace spacing

horizontal alignmentspacingvertical alignment

I am currently using the \underbrace command and would like to center \cdot between the two terms. How can I better format this dot product and also line up the underprice text to the same heights?

Thank you.

Incorrectly spaced

\begin{equation*}
        g'(t)=Df_{\gamma(t)}\left(\gamma'(t)\right)=\underbrace{\nabla f_{\gamma(t)}}_{\text{gradient}} \cdot \underbrace{\gamma'(t)}_{\text{tangent to level line}}
    \end{equation*}

Best Answer

Add an appropriate \vphantom and flatten the longer text horizontally:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}
  g'(t) = Df_{\gamma(t)} \bigl( \gamma'(t) \bigr) 
    = \underbrace{\nabla f_{\gamma(t)}}_{\text{gradient}} \hspace{1.5em} \cdot \hspace{1.5em}
      \underbrace{\vphantom{f_{()}}\gamma'(t)}_{\text{\makebox[0pt]{tangent to level line}}}
\end{equation}

\end{document}

You could also alternate the brace direction:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}
  g'(t) = Df_{\gamma(t)} \bigl( \gamma'(t) \bigr) 
    = \underbrace{\nabla f_{\gamma(t)}}_{\text{gradient}} \cdot
      \overbrace{\gamma'(t)}^{\text{\makebox[0pt]{tangent to level line}}}
\end{equation}

\end{document}
Related Question