tikz 中的 V 形箭头形状

tikz 中的 V 形箭头形状

在 TIKZ 中绘制这个的最佳方法是什么?

在此处输入图片描述

我原本以为可以用这种“箭头”形式定义自定义形状,但不知道该如何实现。也许有更好的解决方案?

答案1

请尝试一下这个:

\documentclass{book}
\usepackage{xcolor}
\usepackage{tikz}%
\usetikzlibrary{shapes.arrows}%
\usetikzlibrary{shapes.symbols}

\def\splarrow#1{%
\begin{tikzpicture}%
[every node/.style={single arrow,draw=none,single arrow head
extend=0pt}]\node[fill=black!50]{\textcolor{white}{#1}};%
\end{tikzpicture}}%

\makeatletter
\tikzset{product size/.style={minimum width=2cm, 
    minimum height=15pt,
    text height=1ex,
  },
  product/.style={ % removed fill and text colour setting
    draw,signal, 
    signal to=east, 
    signal from=west,
    product size,
    draw=white
  },
}
\newcommand{\diagram}[1]{%
 % changed from "\x in" to "\x/\clr in"
 \foreach [count=\xi, count=\prevx from 0] \x/\clr in {#1}{%
  \ifnum\xi=1
    % added fill=\clr,signal from=none
    \node[product,fill=\clr,signal from=none] (x-\xi) {\x};
  \else
    % added fill=\clr
    \node[product,fill=\clr,anchor=west] (x-\xi) at (x-\prevx.east) {\x};
  \fi
 }
}

\newcommand{\arrowtext}[4]{%
\begin{tikzpicture}%
% "text/colour name", instead of just "text"
\diagram{#1/black!50,#2/black!50,#3/black!50,#4/black!50}%
\end{tikzpicture}\ignorespaces%
\@afterheading\@afterindentfalse%
}%
\makeatother

\begin{document}

\arrowtext{Arrow 1}{Arrow 2}{Arrow 3}{Arrow 4}

\end{document}

在此处输入图片描述

答案2

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary {decorations.shapes,shapes.symbols,calc}

\begin{document}
\begin{tikzpicture}
                    [
                    every node/.style={signal, draw, text=white, signal to=nowhere}
                    ]
\node[fill=green!65!black, signal to=east] at (0,1) {To East};
\node[fill=red!65!black, signal from=east] at (0,0) {From East};
\end{tikzpicture}

\end{document}

相关内容