# Annotate math equation with text on arrows around the equation

is there any particular way to get something similar to that in tikz with or without any packages?

• Yes. What have you tried so far? – fractal Jan 1 '20 at 10:54
• Nothing really since I never used tikz for more then using \addplot. But I searched the site for help and found some questions with arrows between textboxes which is not exactly what I need but made me think that there might be a way to get an equation annotated as well. – Nadine Jan 1 '20 at 10:59
• – leandriis Jan 1 '20 at 11:10

This is a continuation of Fractal's nice answer the purpose of which is to make the formulae fit in the document without overlapping.

\documentclass{article}
\usepackage[charter]{mathdesign}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{calc}
\begin{document}
Blah blah blah blah blah blah blah blah blah\dots
\int\limits _{\tikzmarknode{a}{a}} ^{\tikzmarknode{b}{b}}\tikzmarknode{f}{f}(\tikzmarknode{x1}{x}) \,\tikzmarknode{d}{\mathrm{d}}\tikzmarknode{x2}{x} \begin{tikzpicture}[overlay,remember picture,cyan,>=stealth,shorten <=0.2ex,nodes={font=\tiny,align=left,inner ysep=1pt},<-] \draw ([xshift=-0.3ex]b.west|-x2) -- ++ (-1.5em,0) node[left] (l) {\textbf{Integral}}; \draw (a.south) -- ++ (0,-1.5em) node[anchor=north west,align=left,xshift=-1.2ex] (u) {\textbf{Untergrenze}\\ Untere integrationsgrenze}; \draw (b.north) -- ++ (0,1.5em) node[anchor=south west,align=left,xshift=-1.2ex] (o) {\textbf{Obergrenze}\\ Obere integrationsgrenze}; \path (x1.north) ++ (0,1.5em) node[anchor=south west,xshift=-1.2ex] (il) {\textbf{Integrand}\\ Funktion \"uber die integriert werden soll}; \draw (x1.north) |- ([xshift=0.3ex]il.south east); \path (d.south) ++ (0,-1.5em) node[anchor=north west] (diff) {\textbf{Differtential}}; \draw (d.south) |- ([xshift=0.3ex]diff.south east); \draw ([xshift=0.3ex]x2.east) -- ++ (1.5em,0) node[right] (r) {\textbf{Integrationsvariable}\\ Der Integrand wird \"uber x integriert}; \path let \p1=((o.north)-(u.south)),\p2=((r.east)-(x2.east)), \p3=((a.west)-(l.west)),\n1={\x2-\x3} in \pgfextra{\xdef\tmpvspace{\y1}\xdef\tmphspace{\n1}}; \end{tikzpicture}\vcenter{\vspace{\tmpvspace}} \hspace{\tmphspace}
Blah blah blah blah blah blah blah blah blah\dots
$E=m\,c^2$
\end{document}


If you comment out \hspace{\tmphspace} you get

• Thank you so much! This is perfect! I was trying do edit Fractal's answer to add the snaped arrows but could not get the text above the line. That really helps. Thanks again and happy New Year. – Nadine Jan 1 '20 at 12:55
• @Schrodingerscat how to use forest in such a case – js bibra Feb 14 '20 at 3:48
• @jsbibra forest is great for trees, and not necessarily ideal for what is asked here. – user194703 Feb 14 '20 at 3:52
• @Schrödinger'scat agreed-- just wanted to know if there was a way to choose different anchor points on a parent like its done with tikzmarknode – js bibra Feb 14 '20 at 3:54

This is a start.

\documentclass{article}
\usepackage[charter]{mathdesign}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{arrows.meta}
\begin{document}
$\tikzmarknode{int}{}\int\limits _{\tikzmarknode[inner sep=.2em]{a}{a}} ^{\tikzmarknode{b}{b}}\tikzmarknode{f}{f(x)} \,\tikzmarknode{d}{\mathrm{d}}\tikzmarknode{x}{x}$
\begin{tikzpicture}[overlay,remember picture,cyan,>=Stealth]
\draw[<-] (int) -- ++ (-1,0) node[left] {{\bfseries Integral}};
\draw[<-] (a) -- ++ (0,-1) node[anchor=168,align=left]
{{\bfseries Some bold text}\\Some lighter text about something};
\end{tikzpicture}
\end{document}


• Thank you so much! – Nadine Jan 1 '20 at 12:53
• @Fractal how to use forest in such a case – js bibra Feb 14 '20 at 3:47
• See the reply in another answer – fractal Feb 14 '20 at 7:45