TikZ:由两部分组成的箭头

TikZ:由两部分组成的箭头

我想使用 重现以下图片TikZ。箭头分为两半,每半都有特定的颜色和文字。我选择的两种颜色并不重要。

在此处输入图片描述

答案1

最好使用为第二个节点部分制作的新形状声明来完成此操作,但是现在,这里是一个使用path picture并手动指定箭头的宽度和高度的实现。

我认为,如果箭头的头部缩进和头部延伸single arrow tip angle相等90,则会产生类似于您的图像的箭头,但事实似乎并非如此。

代码

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{shapes.arrows}
\makeatletter
\tikzset{
  two part arrow/.style 2 args={
    shape=single arrow,draw,
    single arrow tip angle=90,
    single arrow head extend=.15cm,
    single arrow head indent=0cm,
%    single arrow head indent/.expanded=\pgfkeysvalueof{/pgf/single arrow head extend},% do not work as expected
%    single arrow head extend=\pgfkeysvalueof{/pgf/single arrow head indent},% do not work as expected
    path picture={
      \pgfutil@ifnextchar[\qrr@twopartarrow@split{\qrr@twopartarrow@split[]}#1\@qrr@twopartarrow@split 1%
      \expandafter\path\pgf@tempa (path picture bounding box.north west) rectangle node [every two part arrow node/.try, every two part arrow node 1/.try] {\pgf@tempb} (path picture bounding box.south);
      \pgfutil@ifnextchar[\qrr@twopartarrow@split{\qrr@twopartarrow@split[]}#2\@qrr@twopartarrow@split 2%
      \expandafter\path\pgf@tempa (path picture bounding box.north) rectangle node [every two part arrow node/.try, every two part arrow node 2/.try] {\pgf@tempb} (path picture bounding box.south east);
    }
  }
}
\def\qrr@twopartarrow@split[#1]#2\@qrr@twopartarrow@split#3{\def\pgf@tempa{[every two part arrow path/.try, every two part arrow path #3/.try, #1]}\def\pgf@tempb{#2}}
\makeatother
\tikzset{every two part arrow node/.style={midway,text=black}}
\begin{document}
\begin{tikzpicture}[every two part arrow path/.style={fill}]
  \node [minimum height=3cm, minimum width=1.5cm, two part arrow={[blue!60!green!35]text 1}{[gray!50]text 2}] (a) {};
\end{tikzpicture}
\end{document}

输出

single arrow head indent=0cm

在此处输入图片描述

single arrow head indent=.41cm

在此处输入图片描述

相关内容