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