How can I typeset this equation:
[Tex/LaTex] Equation with a loop arrow (see picture)
arrowsequations
Related Solutions
Add the options remember picture
and overlay
to the connecting drawing commands:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees,positioning}
\author{Apurba Paul}
\begin{document}
\newcommand{\tikzmark}[1]{\tikz[baseline,remember picture] \coordinate (#1) {};}
\tikzset{
square arrow/.style={
to path={-- ++(-10,-.25) -| (\tikztotarget)}
}
}
\begin{gather*}
y=\left[\frac{a}{\tikzmark{a}b}\frac{c}{\tikzmark{b}d}\right]\\[2ex]
\tikz[remember picture]{\node(c){1'st part};}\qquad
\tikz[remember picture]{\node(d){2'nd picture};}
\tikz[remember picture,overlay]{
\draw[->] (a.south)++(.25em,-.3ex) to (c.north) ;
\draw[->] (b.south)++(.25em,-.3ex) to (d.north) ;
}
\end{gather*}
\end{document}
The command \uparrow
makes an extensible arrow.
\documentclass{article}
\usepackage{mathtools}
\newcommand\vertarrowbox[3][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).
Best Answer
Since this seems to be a commutative diagram, you should use a dedicated tools for those kind of diagrams such as
tikz-cd
. Since the package already offers you the required elements, the code now is a one-liner: