7

How can I draw an arrow on a equation in Tikz by defining points?

Here is a starting code.

\documentclass[a4paper]{book}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node at (0,0) {$93  \stackrel{12}{\equiv} - 27 \Rightarrow 93 \stackrel{12}{\equiv} \underbrace{-27 + \overbrace{3 \times 12}}_{9} \Rightarrow 93 \stackrel{12}{\equiv} 9$};
\draw[->] (-.75,.5) -- (-.75,1) -- (1,1) -- (1,.75);
\end{tikzpicture}
\end{document}

enter image description here

3

2 Answers 2

11

Something like this?

arrow from marks

\documentclass[a4paper]{book}

\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
  \node at (0,0) {$93  \stackrel{12}{\equiv} - 27 \Rightarrow 93 \stackrel{\subnode{a}{12}}{\equiv} \underbrace{-27 + \subnode{b}{\overbrace{3 \times 12}}}_{9} \Rightarrow 93 \stackrel{12}{\equiv} 9$};
  \draw [->] (a.north) -- ++(0pt,5mm) -| (b.north);
\end{tikzpicture}
\end{document}
7

enter image description here

\documentclass[a4paper]{book}

\usepackage[x11names]{xcolor}

\usepackage{amsmath}

\usepackage{tikz}
% BEGIN_FOLD

\usetikzlibrary{tikzmark}
\usetikzlibrary{arrows.meta}

% default arrow type
\tikzset{
    >={Triangle[width=1ex, length=1.5ex]}
}

% END_FOLD

\begin{document}
    
\begin{tikzpicture}[remember picture,inner sep=0pt,outer sep=0pt]
    
    \node at (0,0) {
        $93  \stackrel{12}{\equiv} - 27 \Rightarrow 93 \mspace{\thinmuskip} 
        \tikzmarknode{name1}{\stackrel{12}{\mathrel{\equiv}}}
        \mspace{\thinmuskip} \underbrace{-27 +
        \tikzmarknode{name2}{\overbrace{3 \times 12}}_{9}}
        \Rightarrow 93 \stackrel{12}{\equiv} 9$
    };
        
    \draw[thick,color=DodgerBlue3,->] (name1.north) -- ([yshift=1.5em] name1.north) -- ([yshift=1.5em] name1.north -| name2.north) -- (name2.north);
    
\end{tikzpicture}
    
\end{document}
1
  • 1
    Putting a \tikzmarknode inside a tikzpicture involves nesting tikzpictures, which can be problematic. The \subnode command was written for this purpose. Commented Jul 6 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .