LaTeX TikZ:箭头形状

LaTeX TikZ:箭头形状

我面临一个自己无法解决的问题。目标是画一个带有“断线”的箭头,如下所示(但要有箭头):

\documentclass[tikz,border=2mm]{standalone}
\tikzset{ext/.pic={
\path [fill=white] (-0.2,0)to[bend left](0,0.1)to[bend right](0.2,0.2)to(0.2,0)to[bend left](0,-0.1)to[bend right](-0.2,-0.2)--cycle;
\draw (-0.2,0)to[bend left](0,0.1)to[bend right](0.2,0.2) (0.2,0)to[bend left](0,-0.1)to[bend right](-0.2,-0.2);
}}
\begin{document}
\begin{tikzpicture}
\path [draw] (0,0)--pic {ext}(0,2);
\end{tikzpicture}
\end{document}

在此处输入图片描述

我准备了一个 mwe,其中应该实现这个断箭:

\documentclass[tikz,
               border=5mm]{standalone}
\usetikzlibrary{arrows, chains, positioning, shapes.geometric, shapes.symbols}

\tikzset{%
     base/.style = {draw=black, minimum width=3cm, minimum height=1cm,
                    align=center, on chain},
 myarrows/.style = {-stealth, thick},% <-- added on request in comment
  process/.style = {rectangle, base},
startstop/.style = {rectangle, base, rounded corners, fill=red!30},
    }
\begin{document}
    \begin{tikzpicture}[
   node distance = 1cm and 2cm,
     start chain = going below,
                    ]
\node (start) [startstop]   {Start};
\node (pro1)  [process]     {Process};
\node (pro3)  [process]        {List};
%
\draw[myarrows] (start) edge (pro1)
                (pro1)  edge (pro3);

    \end{tikzpicture}
\end{document}

在此处输入图片描述

我希望断开的箭头作为“开始”和“过程”之间的边。我做的几种方法都因为 而产生了错误pic

答案1

pic您需要在图片中添加对 ˙\tikzset` 的定义,然后将其用作

\draw[myarrows] (start) edge pic {ext} (pro1);

就这些!

编辑: 我无法重现您的解决方案中的任何错误。它有效,但得到的结果很糟糕:

在此处输入图片描述

如您所见,在一条线上添加了箭头。这是您对 的定义的结果ext。因此我将其更改为:

ext/.pic = {\draw[white,very thick,-]% <-- observe added - for line type
                                       (0,0) -- (0,0.1);
            \draw[-] (-0.2,0.0) % <-- observe added - for line type
            .. controls +(0.2,0.2) and +(-0.2,-0.2) .. (0.2,0.0)
                     (-0.2,0.1)
            .. controls +(0.2,0.2) and +(-0.2,-0.2) .. (0.2,0.1);
            },

它不再对箭头的形状敏感。有了它,我得到了预期的结果:

在此处输入图片描述

完成 MWE:

\documentclass[tikz,
               border=5mm]{standalone}
\usetikzlibrary{arrows, chains, positioning, shapes.geometric, shapes.symbols}

\tikzset{%
     base/.style = {draw=black, minimum width=3cm, minimum height=1cm,
                    align=center, on chain},
        ext/.pic = {\draw[white,very thick,-] (0,0) -- (0,0.1);
                    \draw[-] (-0.2,0.0)
                    .. controls +(0.2,0.2) and +(-0.2,-0.2) .. (0.2,0.0)
                             (-0.2,0.1)
                    .. controls +(0.2,0.2) and +(-0.2,-0.2) .. (0.2,0.1);                                                },
 myarrows/.style = {-stealth, thick},% <-- added on request in comment
  process/.style = {rectangle, base},
startstop/.style = {rectangle, base, rounded corners, fill=red!30},
    }
\begin{document}
    \begin{tikzpicture}[
   node distance = 1cm and 2cm,
     start chain = going below,
                    ]
\node (start) [startstop]   {Start};
\node (pro1)  [process]     {Process};
\node (pro3)  [process]        {List};
%
\draw[myarrows] (start) edge pic {ext} (pro1) % <-- it works!
                (pro1)  edge (pro3);
    \end{tikzpicture}
\end{document}

相关内容