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 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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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}
share|improve this answer
1  
See the options for the var arc example in the manual p.614. –  percusse Aug 27 '12 at 11:57
    
shoudn't the name of the arrowhead be {|var}{var|}? And the triangles are not possible? What about var|<->var| –  pluton Aug 27 '12 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' –  Sašo Živanović Aug 27 '12 at 12:48

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.