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?
Asked
Active
Viewed 1.1k times
21
-
Welcome to TeX.sx! Your question was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – N.N. Nov 11 '11 at 08:04
-
Could you clarify whether you want the arrow to point to specific parts of the equation or not. – Andrew Stacey Nov 11 '11 at 08:09
-
Should the arrow be straight or curved? – Gonzalo Medina Nov 11 '11 at 14:48
4 Answers
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}

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
-
1Worth 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
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}
Edward Finkelstein
- 74
- 5

