13

How do I make a custom arrowhead in Tikz having a perpendicular bar before a triangle 45? I would also like to adapt this solution to a bar before a square, open square, etc.

For example, imagine arrow coming from (0,0) to (10,0), then the arrowhead would be a filled triangle roughly (9,1) -- (10, 0) -- (9, -1). I want to add a bar, which is a filled rectangle roughly (8.5,1) -- (8.6, 1) -- (8.6, -1) -- (8.5, -1).

I guess I can use pgfdeclarearrow to declar a bar somehow and then pgfarrowsdeclarecombine* to combine it with existing arrows?

5
  • Could you draw a picture using MS paint or something? Dec 16, 2013 at 16:03
  • I think you may want to have a look to Can I combine arrow tips in TikZ/pgf? Dec 16, 2013 at 16:04
  • @JohnKormylo: edited.
    – Neil G
    Dec 16, 2013 at 16:24
  • @ClaudioFiandrino: Thanks, I missed that question, so I'm now closer to a solution.
    – Neil G
    Dec 16, 2013 at 16:25
  • How about defining |> to mean Triangle[open] using \tikzset?
    – Someone
    Dec 3, 2020 at 19:44

1 Answer 1

30

With the arrows.meta library in pgf 3.0 (released December 2013), combining arrow heads is pretty simple and can be done in advance or in-line:

\documentclass[border=0.125cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\tikzset{%
  tipA/.tip={Bar[sep]Triangle[open,angle=45:4pt]},
  tipB/.tip={Bar[sep]Square[open]}
}
\begin{document}

\begin{tikzpicture}
\draw [-tipA] (0,0)  -- +(1,0);
\draw [-tipB] (0,.5) -- +(1,0);
% in-line
\draw [-{Bar[sep]Triangle[angle=45:4pt]}] (0,1)   -- +(1,0);
\draw [-{Bar[sep]Square[]}]   (0,1.5) -- +(1,0);
\end{tikzpicture} 

\end{document}

enter image description here

Just for Thomas:

\documentclass[border=0.125cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usetikzlibrary{arrows.meta}
\tikzset{%
  tipA/.tip={Bar[sep]Triangle[open,angle=45:4pt]},
  tipB/.tip={Bar[sep]Square[open]},
  legs/.tip={Straight Barb[reversed]},
  long legs/.tip={Straight Barb[reversed,angle=30:4pt]},
  hat/.tip={Bracket[reversed,sep=-1pt]Rectangle[]},
  arms/.tip={Bar[sep]},
  head/.tip={Circle[]},
  skirt/.tip={Triangle[reversed]},
  arms down/.tip={Straight Barb[angle=35:4pt]},
  long hair/.tip={Arc Barb[length=9pt,width=6pt,sep=-9pt]Arc Barb[length=9pt,width=5pt,sep=-9pt]Arc Barb[length=9pt,width=7pt]}
}

\begin{document}



\begin{tikzpicture}[x=0.5cm,y=0.5cm]
\draw [legs-tipA] (0,0)  -- +(0,1);
\draw [legs-tipB] (1,0) -- +(0,1);
% in-line
\draw [legs-{Bar[sep]Triangle[angle=45:4pt]}] 
  (2,0)   -- +(0,1);
\draw [legs-{Bar[sep]Square[]}]   
  (3,0) -- +(0,1);
\draw [legs-{arms[]head[sep=-1pt]hat[]}]   
  (4,0) -- +(0,1);
\draw [{long legs[]skirt[sep=-2pt]}-{arms down[]head[sep=-8.5pt]long hair[]}]   
  (5,0) -- +(0,1);
\end{tikzpicture} 

\end{document} 

enter image description here

5
  • installation of arrows.meta
    – Neil G
    Dec 16, 2013 at 18:05
  • 3
    if you bend your head to the right, you will see a bunch of tall people with short arms.
    – Thomas
    Dec 16, 2013 at 19:25
  • 3
    @Thomas and possibly with a hat. Dec 16, 2013 at 19:53
  • 4
    Your edit is awesome !
    – Thomas
    Dec 16, 2013 at 19:57
  • 2
    Got it working, thank you!! Your people example is not only cute, but it's very instructive.
    – Neil G
    Dec 16, 2013 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.