# Curved arrow describing a step in a equation derivation [duplicate]

Is it possible to achieve something like this in LaTeX?

I want a curved arrrow pointing from 1st line to the other line and is coupled with an equation number which indicates the equation used. I want to be able to specify equation used manually like for example

• Jan 18, 2017 at 8:53
• Could you provide an example picture of the desired output and maybe some (non)working code with desired syntax? I don't really understand what's wanted, also it seems to me that (aside from Ignasi's Inputs) tikzmark can do the job. Jan 18, 2017 at 11:58

Make sure that the following packages are loaded:

\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}


\newcommand\sidecomment[5][0.1]%
{\begin{tikzpicture}[remember picture,overlay]
\draw[-stealth]
($({pic cs:#4}|-{pic cs:#2})+(#1,0)$)
.. controls +(0.2,-0.05) and +(0.2,0.1) ..
node[right,align=left]{#5}
($({pic cs:#4}|-{pic cs:#3})+(#1,0.1)$);
\end{tikzpicture}%
}


Add marks at the end of the lines where you want the arrow to start and end using

\tikzmark{name of mark}


Then you can use the command

\sidecomment[offset]{<start mark>}{<end mark>}{<alignment mark>}{<text>}


to draw an arrow from start mark to end mark labeled with text. To align start and end of the arrow vertically, use the rightmost of these two marks additionally as alignment mark. offset is an optional argument that allows to shift start and end of the arrow by the same amount to the right; it is a number x that gives the x-offset in cm. The default is 0.1, i.e., \sidecomment{a}{b}{c}{d} is the same as \sidecomment[0.1]{a}{b}{c}{d}, which means that the arrow starts and ends 1mm to the right of the mark.

Note that you have to run LaTeX twice to get the positions right.

The following document was typeset with the code below it.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\usepackage{amsmath}
\newcommand\sidecomment[5][0.1]%
{\begin{tikzpicture}[remember picture,overlay]
\draw[-stealth]
($({pic cs:#4}|-{pic cs:#2})+(#1,0)$)
.. controls +(0.2,-0.05) and +(0.2,0.1) ..
node[right,align=left]{#5}
($({pic cs:#4}|-{pic cs:#3})+(#1,0.1)$);
\end{tikzpicture}%
}
\begin{document}
\begin{align*}
3\cdot(-4) &=-12\tikzmark{a}\\
2\cdot(-4) &=-8\tikzmark{b}\\
1\cdot(-4) &=-4\tikzmark{c}\\
0\cdot(-4) &=0\tikzmark{d}
\end{align*}
\sidecomment{a}{b}{a}{step 1}
\sidecomment{b}{c}{a}{step 2}
\sidecomment{c}{d}{a}{step 3}
\end{document}


Done as two adjacent stacks. I get the arrow by rotating the AMS arrow, \curvearrowright, by 90 degrees.

\documentclass{article}
\usepackage{tabstackengine,amssymb,graphicx}
\TABstackMath
\stackText
\newcommand\ldsar{\,\raisebox{-2pt}{\rotatebox[origin=bottom]{-90}{$\curvearrowright$}}\,}
\setstackgap{L}{1.1\baselineskip}
\begin{document}
\alignCenterstack{ 3\cdot(-4) =& -12\\ 2\cdot(-4) =& -8\\ 1\cdot(-4) =& -4\\ 0\cdot(-4) =& 0 } \Centerstack[l]{ \ldsar step 1\\ \ldsar step 2\\ \ldsar step 3 }
\end{document}


If desired, one can spread the lines out with \setstackgap{L}{} and magnify the arrow with \scalebox, as in

\documentclass{article}
\usepackage{tabstackengine,amssymb,graphicx}
\TABstackMath
\stackText
\newcommand\ldsar{\,\scalebox{1.4}{%
\raisebox{-3pt}{\rotatebox[origin=bottom]{-90}{$\curvearrowright$}}%
}\,}
\setstackgap{L}{1.2\baselineskip}
\begin{document}
\alignCenterstack{ 3\cdot(-4) =& -12\\ 2\cdot(-4) =& -8\\ 1\cdot(-4) =& -4\\ 0\cdot(-4) =& 0 } \Centerstack[l]{ \ldsar step 1\\ \ldsar step 2\\ \ldsar step 3 }
\end{document}