# TikZ arrow tip is displaced

My quetion is twofold:

1) I want to have a timeline graph with some intervalls. This is my code:

\draw[->|] (8,5)--(10,5);
\node[] (sh4) at (9.5,5.5){$s^{\text{h}}_{4}$};
\draw[|<-] (10,5)--(13,5);
\node[] (stt4) at (11,5.5){$STT_{4}$};


The result looks like this:

The problem is the bold vertical line of the arrow tip. They should be exactly at the same position, such that the vartical line is thinner.

2) How can I make the arrow tips like -]? The following is not working. Seems like one must escape the ]:

\draw[-]] (8,5)--(10,5);


For the ]/[ arrows you will need to load the arrows library and hide that ] from the parser as it would delimit the optional argument [ … ]:

\draw[{-]}] …


If you want to avoid this, you can declare aliases for the ]/[ arrow tips:

\pgfarrowsdeclarealias{brack<}{brack>}{[}{]}
\pgfarrowsdeclarealias{brack<'}{brack>'}{['}{]'}% definition of [' and ]' in this answer


The arrows are usually defined in a way so that they touch the point they point to. You want the | arrow parts to extend over that point. You can either use shorten >=-.5\pgflinewidth or, more comfortably, a slightly changed definition of the arrow tips.

The |<'/>|' arrow tips are set up in such a way that they are usable with the > option (default: >=to).

## Code

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{arrows}
\makeatletter
\pgfarrowsdeclare{|'}{|'}
{
\pgfarrowsleftextend{+-0.25\pgflinewidth}
\pgfarrowsrightextend{+.25\pgflinewidth}
}
{
\pgfutil@tempdima=2pt%
\pgfsetdash{}{+0pt}
\pgfsetrectcap
\pgfpathmoveto{\pgfqpoint{0.25\pgflinewidth}{-\pgfutil@tempdima}}
\pgfpathlineto{\pgfqpoint{0.25\pgflinewidth}{\pgfutil@tempdima}}
\pgfusepathqstroke
}
\pgfarrowsdeclare{['}{]'}
{
\pgfutil@tempdima=1pt%
\pgfarrowsleftextend{+-\pgfutil@tempdima}
\pgfarrowsrightextend{+0pt}
}
{
\pgfutil@tempdima=2pt%
\pgfutil@tempdimb=\pgfutil@tempdima%
\pgfsetdash{}{+0pt}
\pgfsetmiterjoin
\pgfsetbuttcap
\pgfpathmoveto{\pgfqpoint{-.5\pgfutil@tempdimb}{-1\pgfutil@tempdima}}
\pgfpathlineto{\pgfqpoint{0pt}{-1\pgfutil@tempdima}}
\pgfpathlineto{\pgfqpoint{0pt}{\pgfutil@tempdima}}
\pgfpathlineto{\pgfqpoint{-.5\pgfutil@tempdimb}{\pgfutil@tempdima}}
\pgfusepathqstroke
}
\def\tikz@set@pointed#1#2{%
\pgfutil@ifundefined{pgf@arrow@code@tikze@>@#2}
{%
\pgfarrowsdeclarealias{tikzs@<@#2}{tikze@>@#2}{#1}{#2}%
\pgfarrowsdeclarereversed{tikzs@>@#2}{tikze@<@#2}{#1}{#2}%
\pgfarrowsdeclarecombine*{tikz@|<@#2}{tikz@>|@#2}{#1}{#2}{|}{|}%
\pgfarrowsdeclarecombine*{tikz@|<'@#2}{tikz@>|'@#2}{#1}{#2}{|'}{|'}%
\pgfarrowsdeclaredouble[\pgflinewidth]{tikzs@<<@#2}{tikze@>>@#2}{#1}{#2}%<<
\pgfarrowsdeclarereversed{tikzs@>>@#2}{tikze@<<@#2}{tikzs@<<@#2}{tikze@>>@#2}%<<
}{}%
\pgfutil@namedef{tikz@special@arrow@start<}{tikzs@<@#2}%
\pgfutil@namedef{tikz@special@arrow@end>}{tikze@>@#2}%
\pgfutil@namedef{tikz@special@arrow@start>}{tikzs@>@#2}%
\pgfutil@namedef{tikz@special@arrow@end<}{tikze@<@#2}%
\pgfutil@namedef{tikz@special@arrow@start|<}{tikz@|<@#2}%
\pgfutil@namedef{tikz@special@arrow@end>|}{tikz@>|@#2}%
\pgfutil@namedef{tikz@special@arrow@start|<'}{tikz@|<'@#2}%
\pgfutil@namedef{tikz@special@arrow@end>|'}{tikz@>|'@#2}%
\pgfutil@namedef{tikz@special@arrow@start<<}{tikzs@<<@#2}%
\pgfutil@namedef{tikz@special@arrow@end>>}{tikze@>>@#2}%<<
\pgfutil@namedef{tikz@special@arrow@start>>}{tikzs@>>@#2}%<<
\pgfutil@namedef{tikz@special@arrow@end<<}{tikze@<<@#2}%<<
}
\pgfarrowsdeclarecombine*{tikz@|<'@to}{tikz@>|'@to}{to}{to}{|'}{|'}%
\makeatother

\pgfarrowsdeclarereversed{]'}{['}{['}{]'}

\pgfarrowsdeclarealias{brack<}{brack>}{[}{]}
\pgfarrowsdeclarealias{brack<'}{brack>'}{['}{]'}
\begin{document}
\begin{tikzpicture}[>=to]
\draw[->|] (left:1) -- (0,0);
\draw[->|] (right:1) -- (0,0);

\tikzset{yshift=-.5cm}
\draw[shorten >=+-.5\pgflinewidth,->|] (left:1) -- (0,0);
\draw[shorten >=+-.5\pgflinewidth,->|] (right:1) -- (0,0);

\tikzset{yshift=-.5cm}
\draw[->|'] (left:1) -- (0,0);
\draw[->|'] (right:1) -- (0,0);

\tikzset{yshift=-.5cm}
\draw[{-]}] (left:1) -- (0,0);
\draw[{-]}] (right:1) -- (0,0);

\tikzset{yshift=-.5cm}
\draw[shorten >=+-.5\pgflinewidth,{-]}] (left:1) -- (0,0);
\draw[shorten >=+-.5\pgflinewidth,{-]}] (right:1) -- (0,0);

\tikzset{yshift=-.5cm}
\draw[{-]'}] (left:1) -- (0,0);
\draw[{-]'}] (right:1) -- (0,0);

\tikzset{yshift=-.5cm}
\draw[-brack>'] (left:1) -- (0,0);
\draw[-brack>'] (right:1) -- (0,0);
\end{tikzpicture}
\end{document}


## Output

### with >=latex

• superb answer! THX. Apr 27 '13 at 16:26