21

I want to make an arrow under an equation pointing from one part of the equation to another. A bit like an underbrace, but with an arrow. How can I do this?

egreg
  • 1,121,712
twoid
  • 311

4 Answers4

33

Using TikZ, you can place a node for the starting point of the arrow and another one for the ending point, and then join the nodes using the kind of arrow that you desire; a little example, using a curved red arrow and some code to place the nodes borrowed from this answer by Andrew Stacey:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}

\begin{equation}
  a\tikzmark{a}x^2 + bx + c = 5\tikzmark{b}x^2 + bx + c.
  \begin{tikzpicture}[overlay,remember picture,out=315,in=225,distance=0.4cm]
    \draw[->,red,shorten >=3pt,shorten <=3pt] (a.center) to (b.center);
  \end{tikzpicture}
\end{equation}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Can this be improved to enable similar arrows that appear on the top as well? – Greg Mattes Feb 13 '18 at 22:19
  • 1
    Worth noting that the tikzmark command is now available as part of the tikzmark tikz library. The exact replacement for the command here is \tikzmarknode – Andrew Stacey Feb 23 '23 at 06:58
8

Try this one:

\underrightarrow{y = ax^2 + bx + c}

It will look like this:

formula

vharavy
  • 181
5

The document mathmode has the sections Over- and underbrackets and Extensible arrows

If you want to define your own style please have a look into the the linked document. An example of the document is shown below.

\documentclass{article}

\usepackage{amsmath}
\makeatletter
\def\mapstofill@{%
\arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
\newcommand*\xmapsto[2][]{%
\ext@arrow0099\mapstofill@{#1}{\displaystyle#2}}
\makeatother
\begin{document}

$\underrightarrow{y = ax^2 + bx + c}$


$\xmapsto{y = ax^2 + bx + c}$
\end{document}

Marco Daniel
  • 95,681
1

You could also put the equation inside the tikzpicture environment, and then simply draw the line using controls. Here is a MWE. You can adjust the length of the line as you find suitable.

\begin{tikzpicture}
$\begin{aligned}
\left<\theta_{\mathrm{space}}^2\right> = \left<\theta_y^2\right> + \left<\theta_x^2\right> = 2 \left<\theta_{\mathrm{plane}}^2\right> = \theta_{\mathrm{plane}}^2
\draw[<->] (-4.43,-0.2)  .. controls (-4.065,-0.7) .. (-3.7,-0.2);
\node[] at (-4.065,-0.45) {\small =};
\end{aligned}$
\end{tikzpicture}

enter image description here