如何在两张 tikz 图片之间绘制带有文字的大箭头?

如何在两张 tikz 图片之间绘制带有文字的大箭头?

我有两个图表,我想在它们之间画一个箭头,并在箭头中写一条简短的文字信息。我想我会使用花式箭头。但是我不确定如何将它放在两个图之间。这是我的 MWE,箭头线被注释掉了。如果我取消注释,我会得到“TeX 容量超出”。

\documentclass[standalone]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shadows, fadings,shapes.arrows}
\tikzset{My Arrow Style/.style={single arrow, fill=red!50, anchor=base, align=center,text width=2.8cm}}
\newcommand{\MyArrow}[2][]{\tikz[baseline] \node [My Arrow Style,#1] {#2};}

\begin{document}
\begin{frame}
    \begin{center}
    \begin{tikzpicture}[scale=0.6]
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (0, 0) {1};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (2, -2) {2};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (3) at (4, -4) {3};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (4) at (6, -6) {4};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (5) at (8, -8) {5};
    \path (1) edge [loop above] node {} (1);
    \path (2) edge [->] node {} (1);
    \path (3) edge [->] node {} (2);
    \path (4) edge [->] node {} (3);
    \path (5) edge [->] node {} (4);
    %\MyArrow[fill=yellow!50, draw=black, ultra thick, text width=3.5cm]{some text}
    \begin{scope}[shift={(13cm, -1cm)}]
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (0,0) {1};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (-2, -2) {2};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (3) at (0,-2) {3};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (4) at (2, -2) {4};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (5) at (4, -2) {5};

    \path (1) edge [loop above] node {} (1);
    \path (2) edge [->] node {} (1);
    \path (3) edge [->] node {} (1);
    \path (4) edge [->] node {} (1);
    \path (5) edge [->] node {} (1);
    \end{scope}
    \end{tikzpicture}
\end{center}
\end{frame}
\end{document}

答案1

正如您所定义的,此箭头是 TikZ 。因此,创建 LaTeX 命令来绘制它是没有意义的,只需使用您创建的node样式即可。My Arrow Style

为了将它与图书馆一起放置,我将positioning其放在right of the north anchornode (2)

\node[My Arrow Style,right=of 2.north]{some text};

截屏

\documentclass[standalone]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, shadows, fadings,shapes.arrows,positioning}
\tikzset{My Arrow Style/.style={single arrow, fill=red!50, anchor=base, align=center,text width=2.8cm}}
%\newcommand{\MyArrow}[2][]{\tikz[baseline] \node [My Arrow Style,#1] {#2};}

\begin{document}
\begin{frame}
    \begin{center}
    \begin{tikzpicture}[scale=0.6]
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (0, 0) {1};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (2, -2) {2};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (3) at (4, -4) {3};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (4) at (6, -6) {4};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (5) at (8, -8) {5};
    \path (1) edge [loop above] node {} (1);
    \path (2) edge [->] node {} (1);
    \path (3) edge [->] node {} (2);
    \path (4) edge [->] node {} (3);
    \path (5) edge [->] node {} (4);
    \node[My Arrow Style,right=of 2.north]{some text};
    \begin{scope}[shift={(13cm, -1cm)}]
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (1) at (0,0) {1};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (2) at (-2, -2) {2};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (3) at (0,-2) {3};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (4) at (2, -2) {4};
    \node[shape=circle,draw=black,fill=white, drop shadow,minimum size=1cm] (5) at (4, -2) {5};

    \path (1) edge [loop above] node {} (1);
    \path (2) edge [->] node {} (1);
    \path (3) edge [->] node {} (1);
    \path (4) edge [->] node {} (1);
    \path (5) edge [->] node {} (1);
    \end{scope}
    \end{tikzpicture}
\end{center}
\end{frame}
\end{document}

相关内容