如何通过定义点arrow在方程上绘制?Tikz

这是一个起始代码。

\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}

3

  • 4
    也许可以用tikzmark


    – 

  • 可能重复


    – 

  • 您是否需要将方程式放在 tikzpicture 中的节点内,或者只是因为您认为这是获取箭头的最佳方式?


    – 


最佳答案
2

像这样吗?

\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}

\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

  • 将 放入\tikzmarknodetikzpicture 中会涉及嵌套 tikzpictures,这可能会带来问题。该\subnode命令就是为此目的而编写的。


    –