Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to draw a partial arrow (i.e. with only "half" of the tip) but with a triangular tip shape (e.g. using >=latex), instead of the standard single line you get with "left to", "right to", etc.

The result should be something like the following image:

Triangular partial arrow

How can I achieve this? I haven't seen any such tip in the TikZ/PGF manual.

share|improve this question
    
possible duplicate of Harpoons in TikZ –  Jubobs Oct 15 '13 at 10:14
    
@Jubobs: I don't think this is a duplicate. Indeed, Didac asked for triangular tip shapes and if I'm not wrong, at the moment they are missing. –  Claudio Fiandrino Oct 15 '13 at 10:24
    
I haven't found any that matched, but your search might be improved by knowing that the symbol to which you refer is often called a "harpoon" rather than a "partial triangular arrow". –  Steven B. Segletes Oct 15 '13 at 10:24
    
@ClaudioFiandrino Fair enough. –  Jubobs Oct 15 '13 at 10:25
add comment

2 Answers 2

up vote 9 down vote accepted

The new really cool CVS arrow stuff (bendy arrows!) written by Till Tantau makes all sorts of customization of arrows possible. In particular left and right parts of arrows can be specified like this -{Stealth[left]}

This example is culled from the latest CVS manual:

\documentclass[border=0.125cm]{standalone}

\usepackage{tikz}

\usetikzlibrary{arrows.meta}

\makeatletter
\long\def\arrowexample#1{%
    \tt#1 &
    \tikz\draw [-{#1}, very thick](0,0) -- (1,0);
    \\
}
\begin{document}

\begin{tabular}{ll}
    \arrowexample{Stealth[]}
    \arrowexample{Stealth[sep] Stealth[]}
    \arrowexample{Stealth[sep] . Stealth[]}
    \arrowexample{Stealth[open]}
    \arrowexample{Stealth[length=6pt,width=4pt]}
    \arrowexample{Stealth[length=6pt,width=4pt,inset=1.5pt]}
    \arrowexample{Stealth[round]}
    \arrowexample{Stealth[slant=.3]}
    \arrowexample{Stealth[left]}
    \arrowexample{Stealth[right]}
    \arrowexample{Stealth[red]}
\end{tabular}

\end{document}

enter image description here

share|improve this answer
    
That looks super cool! Is there an easy way to install the arrows.meta library (without having to download to full CVS directory and doing manual installation -- I don't want to mess up my current TikZ system. –  Didac Busquets Oct 15 '13 at 13:58
    
@DidacBusquets As I understand it, all the code for arrows has been completely rewritten from scratch and this involves multiple files not just the arrows.meta library. Most people find it quite simple to update using the latest CVS though as explained here. –  Mark Wibrow Oct 16 '13 at 6:14
    
I got it working! –  Didac Busquets Oct 16 '13 at 10:05
add comment

Luigi, out TikZ-arrows guru provided in the Italian forum something very close to this question (for stealth tip).

Building on that:

\documentclass[tikz,border=10pt]{standalone}

\usepackage{tikz}

\makeatletter
\pgfarrowsdeclare{left stealth}{left stealth}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfarrowsleftextend{+-3\pgfutil@tempdima}
  \pgfarrowsrightextend{+5\pgfutil@tempdima}
}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfmathsetlength\pgfutil@tempdimb{5\pgfutil@tempdima-\pgflinewidth}
  \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}}
  \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{4\pgfutil@tempdima}}
  \pgfpathlineto{\pgfpointorigin}
  \pgfpathlineto{\pgfqpoint{0pt}{-.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{\pgfutil@tempdimb}{-.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{6\pgfutil@tempdima}{-0.5\pgflinewidth}}
  \pgfusepathqfill
}

\pgfarrowsdeclare{right stealth}{right stealth}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfarrowsleftextend{+-3\pgfutil@tempdima}
  \pgfarrowsrightextend{+5\pgfutil@tempdima}
}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfmathsetlength\pgfutil@tempdimb{5\pgfutil@tempdima-0.5\pgflinewidth}
  \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}}
  \pgfpathlineto{\pgfqpoint{-3\pgfutil@tempdima}{-4\pgfutil@tempdima}}
  \pgfpathlineto{\pgfpointorigin}
  \pgfpathlineto{\pgfqpoint{0pt}{.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{\pgfutil@tempdimb}{0.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{6\pgfutil@tempdima}{0.5\pgflinewidth}}
  \pgfusepathqfill
}

\pgfarrowsdeclare{left triangle}{left triangle}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfarrowsleftextend{+-3\pgfutil@tempdima}
  \pgfarrowsrightextend{+5\pgfutil@tempdima}
}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfmathsetlength\pgfutil@tempdimb{5\pgfutil@tempdima-\pgflinewidth}
  \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}}
  \pgfpathlineto{\pgfqpoint{0pt}{4\pgfutil@tempdima}}
  \pgfpathlineto{\pgfpointorigin}
  \pgfpathlineto{\pgfqpoint{0pt}{-.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{\pgfutil@tempdimb}{-.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{5.5\pgfutil@tempdima}{-0.5\pgflinewidth}}
  \pgfusepathqfill
}

\pgfarrowsdeclare{right triangle}{right triangle}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfarrowsleftextend{+-3\pgfutil@tempdima}
  \pgfarrowsrightextend{+5\pgfutil@tempdima}
}
{
  \pgfutil@tempdima=0.28pt%
  \pgfutil@tempdimb=\pgflinewidth%
  \ifdim\pgfinnerlinewidth>0pt%
    \pgfmathsetlength\pgfutil@tempdimb{.6\pgflinewidth-.4*\pgfinnerlinewidth}%
  \fi%
  \advance\pgfutil@tempdima by.3\pgfutil@tempdimb%
  \pgfmathsetlength\pgfutil@tempdimb{5\pgfutil@tempdima-0.5\pgflinewidth}
  \pgfpathmoveto{\pgfqpoint{5\pgfutil@tempdima}{0pt}}
  \pgfpathlineto{\pgfqpoint{0pt}{-4\pgfutil@tempdima}}
  \pgfpathlineto{\pgfpointorigin}
  \pgfpathlineto{\pgfqpoint{0pt}{.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{\pgfutil@tempdimb}{0.5\pgflinewidth}}
  \pgfpathlineto{\pgfqpoint{5.5\pgfutil@tempdima}{0.5\pgflinewidth}}
  \pgfusepathqfill
}

\makeatother

\begin{document}

\begin{tikzpicture}
\draw[right stealth-right stealth]   (0,0)--(2,0);
\draw[left stealth-left stealth]     (0,1)--(2,1);
\draw[right triangle-right triangle] (0,2)--(2,2);
\draw[left triangle-left triangle]   (0,3)--(2,3);
\end{tikzpicture}
\end{document}

The result:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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