# 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);


Previous versions of this answer used the now deprecated arrows library. The newer (but at this point old) arrows.meta library allows for a very easy solution for your first problem. The old answer can be find in the history. We'll be using Bar instead of | and Bracket instead of ], however, we will define | and ] as shorthands again (via the .tip handler).

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. In the code below, this is denoted by the ' behind the shorthand.

Since ] will be a troublemaker in many places for options we can simply define a(nother) shorthand.

## Code

\documentclass[tikz,border=1pt]{standalone}
\usetikzlibrary{arrows.meta}
\tikzset{
|-|/.tip   = Bar[],
|'-|'/.tip ={Bar[sep=0pt -.5 1]},
[-]/.tip   = Bracket[],
['-]'/.tip ={Bracket[sep=0pt -.5 1]},
(-)/.tip   = Parenthesis[],
('-)'/.tip ={Parenthesis[sep=0pt -.5 1]},
% aliases
brack/.tip  = ],
brack'/.tip = ]',
}
\begin{document}
\begin{tikzpicture}[
>=To,
p/.pic={\draw[pic actions](left:.3)--(0,0);\draw[pic actions](right:.3)--(0,0);}
]
\matrix[
row sep=1mm,
row 1/.style={nodes={anchor=base,font=\scriptsize}},
column 2/.style={shorten >=+-.5\pgflinewidth}
]{
\node{normal}; & \node{shortening}; & \node{new tip}; \\
\pic[->|]   {p}; & \pic[->|]   {p}; & \pic[->.|']  {p}; \\
\pic[-{]}]  {p}; & \pic[-{]}]  {p}; & \pic[-{]'}]  {p}; \\
\pic[-brack]{p}; & \pic[-brack]{p}; & \pic[-brack']{p}; \\
\pic[-)]    {p}; & \pic[-)]    {p}; & \pic[-)']    {p}; \\
};
\end{tikzpicture}
\end{document}


## Output

• superb answer! THX. Commented Apr 27, 2013 at 16:26
• @Qrrbrbirlbel How would you do this with parenthesis?
– Jon
Commented Sep 3, 2022 at 23:20
• @Jon I've updated my answer. The newer (but at this point also old) arrows.meta library provides a very easy interface to alter arrow tips. Commented Sep 5, 2022 at 8:28
• @Qrrbrbirlbel Thanks for updating the answer!
– Jon
Commented Sep 5, 2022 at 13:23