6

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*}
6

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}
3

A full working example:

\documentclass{article}

\usepackage{amsmath}
\usepackage{calc}

\begin{document}

\newlength{\lowerlength}
\newlength{\upperlength}
\newlength{\correction}
\setlength{\upperlength}{\widthof{$\gamma'(t)$}}
\setlength{\lowerlength}{\widthof{\scriptsize tangent to level line}}
\setlength{\correction}{(\lowerlength-\upperlength)*\real{0.5}}

\begin{equation*}
  g'(t)=Df_{\gamma(t)}\left(\gamma'(t)\right)=\underbrace{\nabla f_{\gamma(t)}}_{\text{gradient}} \;\quad\cdot\quad\; {\underbrace{\gamma'(t)\llap{\phantom{$_{()}$}}}_{\hspace{-\correction}\text{tangent to level line}\hspace{-\correction}}}
\end{equation*}
\end{document}

The calc package can be used to calculate with lengths, and it provides an easy method of computing lengths of text. Adding negative space to the subscript prevents the second factor from moving too far right.

To align the two underbraces vertically, we need to make both factors seem to have the same height. The crucial point here are the parentheses in the subscript of the first factor. So we add them to the second factor invisibly (\phantom) and let TeX ignore their height (\llap).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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