3

I am quite happy with the |<->| arrowhead in Tikz but I would like to control the length of the |. Is there a simple way to achieve this? In tikz.code.tex, I could find

\pgfarrowsdeclarecombine*{tikz@|<@#2}{tikz@>|@#2}{#1}{#2}{|}{|}

which is somehow related to the question but it looks like in pgflibraryarrows.code.tex there is nothing to grab. It would be nice if this | length could be a parameter.

1 Answer 1

3

A much improved answer, thanks to percusse's information that arrowhead parameters can be set (and read) using \pgfsetarrowoption (and \pgfgetarrowoptions).

The declaration below is adjusted from pgf's declaration of |.

\documentclass{article}
\usepackage{tikz}

\pgfarrowsdeclare{var|}{|var}
{
  \pgfarrowsleftextend{+-0.25\pgflinewidth}
  \pgfarrowsrightextend{+.75\pgflinewidth}
}
{
  \pgfsetdash{}{+0pt}
  \pgfsetrectcap
  \pgfpathmoveto{\pgfqpoint{0.25\pgflinewidth}{-\pgfgetarrowoptions{var|}}}
  \pgfpathlineto{\pgfqpoint{0.25\pgflinewidth}{\pgfgetarrowoptions{var|}}}
  \pgfusepathqstroke
}

\pgfarrowsdeclarecombine*{var|<}{>|var}{to}{to}{var|}{|var}
\begin{document}
\pgfsetarrowoptions{var|}{10pt}
\tikz{
  \draw[var|-|var] (0,0)--(1,1);
  \draw[var|<->|var] (1,0)--(2,1);
}
\end{document}
3
  • 1
    See the options for the var arc example in the manual p.614.
    – percusse
    Commented Aug 27, 2012 at 11:57
  • shoudn't the name of the arrowhead be {|var}{var|}? And the triangles are not possible? What about var|<->var|
    – pluton
    Commented Aug 27, 2012 at 12:28
  • 1
    yes, I guess {|var}{var|} is prettier. Triangles... you mean the combined arrow? I've included a declaration for var|<...`>|var' Commented Aug 27, 2012 at 12:48

You must log in to answer this question.

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