8

I would like to reproduce the following picture using TikZ. The arrow is split into two halves, and each half has a particular color and text. The two colors I chose are not important.

enter image description here

1 Answer 1

10

This would be done best with a new shape declaration that is made for a second node part, but for now, here is an implementation using the path picture and manually specifying the width and height of the arrow.

I thought that with an single arrow tip angle of 90 equal head indent and head extend should result in an arrow tip similar to your image, this seems to be not the case.

Code

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

Output

single arrow head indent=0cm

enter image description here

single arrow head indent=.41cm

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .