# how can you point the head of an arrow from tikzpicture to an equation in LaTex? [duplicate]

I could create a page like this: using the following code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{fit, calc}
\usepackage{fontspec}
\newfontfamily{\myfont}{Arial}
\usepackage{marginnote}
\newcommand\commentary{%
\tikz[remember picture, baseline={(here.base)}] \node (here) {#1};%
\marginpar{
\begin{tikzpicture}[remember picture, overlay]
\begin{scope}[rotate=(rand*10),shift={(1.8,0)}]
\node [text width=3cm, align=center, transform shape] (text) at (0, 0)   {\footnotesize \myfont #2};
\draw [transform shape, thick] plot [smooth, tension=0.8] coordinates {
($(text.south) + (-10pt, -5pt) + (rand * 2pt, rand * 2pt)$)
($(text.south east) + (-5pt, 5pt)$)
($(text.north east) + (rand * 2pt - 5pt, rand * 2pt)$)
($(text.north west) + (rand * 2pt + 5pt, rand * 2pt)$)
($(text.south west) + (rand * 2pt + 5pt, rand * 2pt)$)
($(text.south) + (10pt, -3pt) + (rand * 2pt, rand * 2pt)$)
};
\end{scope}
\draw[->, thick] ($(text.south west) - (-10pt, 5pt)$)  to [bend left=20] ($(here.south east) - (3pt, 2pt)$);
\end{tikzpicture}
}
}

\begin{document}
The equation of a plane through $(x_0,y_0,z_0)$ \commentary{is:}{The tangent   plane: $\nabla f(\mathbf{x})\cdot (\mathbf{x}-\mathbf{x}_0)=0$.}
$$a(x-x_0)+b(y-y_0)+c(z-z_0)=0$$
The vector $(a,b,c)$ is normal to the plane.

\end{document}


1) How can put the head of the arrow to the equation (for example to + sign in the display question) instead of a word in the text (intead of "is :" in this example)?

(2) How can I move the text bubble 1 cm to up or down?

• Unrelated to the question, but don't use $$…$$ for displayed equations: this is plain TeX syntax, and it can yield bad spacing. Apr 16 '17 at 19:35

Use the command

\tikznode[..options..]{..label..}{..contents..}


to mark the contents that the arrow should point to; in your case the equation:

\tikznode{equation}{$a(x-x_0)+b(y-y_0)+c(z-z_0)=0$}


To add arrow and text, use

\begin{tikzpicture}[remember picture,overlay]
... tikz code using the label defined by \tikznode ...
\end{tikzpicture}


Define the command \tikznode in the preamble as

\usepackage{tikz}
\newcommand\tikznode[]%
{\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}


You have to run LaTeX at least twice until the information about the positions has propagated everywhere.

To position the ellipse at the right border we first compute a point on the current page that is 3cm to the left of the right border

\path let \p1=($(current page.east)-(3,0)$) in


and use it to define the position of the center of the ellipse as being horizontally on the same level as the node equation and below/above \p1:

(equation-|\p1) node [ellipse,...] (remark) {...};


Now you can shift the node e.g. up by 1cm with the option yshift.

(equation-|\p1) node [ellipse,yshift=1cm,...] (remark) {...}; \documentclass{article}

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

\newcommand\tikznode[]%
{\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}

\begin{document}
The equation of a plane through $(x_0,y_0,z_0)$ is:
$\tikznode{equation}{a(x-x_0)+b(y-y_0)+c(z-z_0)=0}$
The vector $(a,b,c)$ is normal to the plane.

\begin{tikzpicture}[remember picture,overlay]
\path let \p1=($(current page.east)-(3,0)$) in (equation-|\p1)
node [ellipse,draw,align=center,rotate=30,yshift=1cm] (remark)
{The tangent plane:\\
$\nabla f(\mathbf{x})\cdot (\mathbf{x}-\mathbf{x}_0)=0$.%
};
\draw[<-,shorten <=2pt] (equation) to[bend left=10] (remark);
\end{tikzpicture}
\end{document}