# Equation with vertical arrow

How I get this equation with vertical arrows that help describe some of its terms?

\begin{equation*}
0 \leq F = \underbrace{\sum\limits_{i=1}^{n}(y_i - \overline{y})^2}_{(n-1)s_y^2}
- 2b \underbrace{\sum\limits_{i=1}^{n}(x_i - \overline{x})(y_i - \overline{y})}_{(n-1)s_{xy} = (n-1)rs_xs_y}
+b^2 \underbrace{\sum\limits_{i=1}^{n}(x_i - \overline{x})^2}_{(n-1)s_x^2}
\end{equation*} • welcome to tex.se! please make your code snippet complete and than extend it to small document with your equation. – Zarko Sep 4 '18 at 19:38

The command \uparrow makes an extensible arrow.

\documentclass{article}
\usepackage{mathtools}

\newcommand\vertarrowbox[6ex]{%
\begin{array}[t]{@{}c@{}} #2 \\
\left\uparrow\vcenter{\hrule height #1}\right.\kern-\nulldelimiterspace\\
\makebox[0pt]{\scriptsize#3}
\end{array}%
}
\begin{document}

\begin{equation*}
0 \leq F =
{\underbrace{\sum_{i=1}^{n}(y_i-\bar{y})^2}_{(n-1)s_y^2}}
-\vertarrowbox{2b}{text}
{\underbrace{{}\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}_{(n-1)s_{xy} = (n-1)rs_xs_y}}
+\vertarrowbox{b^2}{More text}
{\underbrace{{}\sum_{i=1}^{n}(x_i-\bar{x})^2}_{(n-1)s_x^2}}
\end{equation*}

\begin{equation*}
0 \leq F =
\sum_{i=1}^{n}(y_i-\bar{y})^2
-2b
\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})
+b^2
\sum_{i=1}^{n}(x_i-\bar{x})^2
\end{equation*}

\end{document}


The strange braces can be easily explained: \underbrace makes an Op atom, which conflicts with the spacing of binary operations, so it's best to brace it. However, if \sum is preceded by an ordinary symbol, a thin space should appear, which is produced by the empty subformula {} inside \underbrace when necessary.

The second display shows the standard spacing without \underbrace and the arrows, just for checking the spaces are the same.

The \vertarrowbox has an optional argument for the desired height of the arrow, default 6ex. Call it as \vertarrowbox[12ex]{<symbol>}{<text>} if you want to double the height (its size should depend on context). • I didn't aware, until I saw your solution, of the fact that \uparrow is extensible and thus can be resized using the \left and \right machinery. Good stuff! – Mico Sep 5 '18 at 14:06
• Can this be used to describe an exponent somehow? Such as e^{-\vertarrowbox{\lambda}{Some text}t}. Without any changes this moves up the exponent instead of moving down the text – blenderfreaky Jan 21 at 10:09
• @blenderfreaky If it's not the only description, then e^{-\smash{\!\vertarrowbox{\scriptstyle\lambda}{Some text}\!}t} should do. – egreg Jan 21 at 11:23

Something like this? Observe that the solution sets a macro called \vertarrowbox, which takes two arguments: (a) the stuff to be placed on the main line of the equation, and (b) the text to be placed below the long vertical arrow. \documentclass{article}
\usepackage{mathtools,graphicx}
\newcommand\vertarrowbox{%
\begin{array}[t]{@{}c@{}} #1 \\
\rotatebox{90}{$\xrightarrow{\hphantom{abcdefgh}}$} \$-1ex] \mathclap{\scriptstyle\text{#2}}% \end{array}} \begin{document} \begin{equation*} 0 \leq F = \underbrace{\sum_{i=1}^{n}(y_i-\bar{y})^2}% _{(n-1)s_y^2} {}-{}\vertarrowbox{2b}{text} \underbrace{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}% _{(n-1)s_{xy} = (n-1)rs_xs_y} {}+{}\vertarrowbox{b^2}{More text} \underbrace{\sum_{i=1}^{n}(x_i-\bar{x})^2}% _{(n-1)s_x^2} \end{equation*} \end{document}  • what a competition! you overtook me for 12 seconds. i obviously need a new, faster PC :-). +1 for nice answer – Zarko Sep 4 '18 at 19:59 • @Zarko - Thanks!! I've upvoted your answer in the meantime too. :-) – Mico Sep 4 '18 at 20:01 • To the OP: Note that I've also replaced all instances of \overline with \bar. – Mico Sep 4 '18 at 20:09 • \phantom{\smash{...}}? Why not \hphantom? But rotating is just wrong. ;-) – egreg Sep 4 '18 at 20:43 • @egreg - Good observation about replacing \phantom{\smash{...}} with \hphantom{...} ;-) – Mico Sep 4 '18 at 20:56 one possibilities is use of the package tikz and its tikzmark library: \documentclass{article} \usepackage{tikz} \usetikzlibrary{tikzmark} \usepackage{lipsum}% for dummy text \begin{document} \lipsum* \[ 0 \leq F = \underbrace{\sum_{i=1}^{n}(y_i - \overline{y})^2}_{(n-1)s_y^2} - \tikzmark{A}2b \underbrace{\sum_{i=1}^{n}(x_i - \overline{x})(y_i - \overline{y})}_{(n-1)s_{xy} = (n-1)rs_xs_y} + \tikzmark{B}b^2 \underbrace{\sum_{i=1}^{n}(x_i - \overline{x})^2}_{(n-1)s_x^2} \begin{tikzpicture}[overlay, remember picture,shorten <=1mm,font=\footnotesize] \draw[<-] ([xshift=1.0ex] pic cs:A) -- ++ (0,-1.2) node[below] {text}; \draw[<-] ([xshift=0.5ex] pic cs:B) -- ++ (0,-1.2) node[below] {text}; \end{tikzpicture} \bigskip$
\lipsum*
\end{document} • +1. Purely aesthetically, I think it's desirable to typeset the explanatory text blocks with \footnotesize or even \scriptsize. – Mico Sep 4 '18 at 20:00
• @Mico, thank you for suggestion. corrected now. – Zarko Sep 4 '18 at 20:36

A short code with pstricks and auto-pst-pdf:

\documentclass{article}
\usepackage{amsmath}
\usepackage{pst-node, auto-pst-pdf}

\begin{document}

\begin{postscript}
\begin{equation*}
0 \leq F = \underbrace{\sum\limits_{i=1}^{n}(y_i - \overline{y})^2}_{(n-1)s_y^2}
{}-\rnode{B}{2b} \underbrace{\sum\limits_{i=1}^{n}(x_i - \overline{x})(y_i - \overline{y})}_{(n-1)s_{xy} = (n-1)rs_xs_y}
{}+\rnode{b2}{b^2} \underbrace{\sum\limits_{i=1}^{n}(x_i - \overline{x})^2}_{(n-1)s_x^2}
\end{equation*}
\psset{arrowinset=0.12, arrows=->, nodesep=4pt}
\uput{12ex}[d](B){\rnode[t]{T1}{\textsf{Text}}}\ncline{T1}{B}
\uput{12ex}[d](b2){\rnode[t]{T2}{\textsf{Text}}}\ncline{T2}{b2}
\end{postscript}

\end{document} • +1. To make the - and + terms between the summands act like binary rather than as unary operators, I think it's a good idea to surround them with pairs of curly braces, i.e., to write them as {}-{} and {}+{}, resp. Also, the three \limits directives aren't needed. – Mico Sep 4 '18 at 20:06
• @Mico: One pair of braces for each node will do. Actually, it has nothing to do with the pstricks nodes (never noticed it previously): it seems to come from the \underbraces. – Bernard Sep 4 '18 at 20:18
• I only ever noticed the spacing issue after coming across a comment by @egreg on this topic, i.e., the presence of \underbrace directives.... – Mico Sep 4 '18 at 20:24